当前位置: 首页 > news >正文

中学生制作的网站外贸网站建设推广公司

中学生制作的网站,外贸网站建设推广公司,企业网站申请流程,泉州网站的建设最初可运行代码 弹窗组件代码&#xff1a; &#xff08;后来发现以下代码可运行&#xff0c;但打包 typescript 类型检查出错&#xff0c;可打包的代码在文末&#xff09; <template><div v-if"isVisible" class"dialog"><div class&quo…

最初可运行代码

弹窗组件代码:

(后来发现以下代码可运行,但打包 typescript 类型检查出错,可打包的代码在文末)

<template><div v-if="isVisible" class="dialog"><div class="dialog-content"><div style="padding: 40px 40px; text-align: center">{{message}}</div><div style="display: flex; border-top: 1px solid #d2d0d0"><div @click="cancel" class="dialog-button">取消</div><div style="border-right: 1px solid #d2d0d0"></div><div @click="handleConfirm" class="dialog-button" style="color: #4e8fd3">确定</div></div></div></div>
</template><script setup lang="ts">
import { ref } from 'vue';const isVisible = ref(false);
const message = ref('');
const confirmCallback = ref(null)
const cancelCallback = ref(null);const showDialog = (params = {} ) => {isVisible.value = true;message.value = params.message || '提示内容';confirmCallback.value = params.confirmCallback || null;cancelCallback.value = params.cancelCallback || null;
};const handleConfirm = () => {if (confirmCallback.value) {confirmCallback.value();}isVisible.value = false;
};const cancel = () => {if (cancelCallback.value) {cancelCallback.value();}isVisible.value = false;
};defineExpose({showDialog
});
</script><style scoped>
.dialog {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.5);display: flex;justify-content: center;align-items: center;font-size: 16px;
}.dialog-content {background-color: #fff;border-radius: 10px;width: 80%;
}.dialog-button {flex-grow: 1;text-align: center;padding: 20px 0;
}
</style>

效果:更适用于移动端

弹窗显示:

<template><div><button @click="openDialog">打开弹窗</button><ChildDialg ref="dialogRef" /></div>
</template><script setup lang="ts">
import { ref } from 'vue';// 1. 引入子组件
import ChildDialg from "@/views/components/ChildDialg.vue";// 2. 定义子组件 ref 参数
const dialogRef = ref(null);const openDialog = () => {// 3. 弹窗显示dialogRef.value.showDialog({message: '内容',confirCallback: () => {}});
};
</script>

打包 typescript 检查错误修复

######## 项目打包,typescript 类型检查报错 ###########

1. 函数接收类没有属性定义

2. 调用弹窗时未作 组件 非空判断

3. 接收的回调函数参数,定义的初始值为 null ,无法以函数方式调用

4. 定义的组件 ref 参数默认值为 null ,无法调用子组件暴露的函数

5. 子组件定义的参数 与 父组件传递的参数不一致(定义了取消回调,但没有传入)

可以选择传入“取消”操作的回调函数,但考虑到此组件在我实际运用时取消没有其它操作,便选择不定义其回调函数

最终可打包的代码

<template><div v-if="isVisible" class="dialog"><div class="dialog-content"><div style="padding: 40px 40px; text-align: center">{{message}}</div><div style="display: flex; border-top: 1px solid #d2d0d0"><div @click="cancel" class="dialog-button">取消</div><div style="border-right: 1px solid #d2d0d0"></div><div @click="handleConfirm" class="dialog-button" style="color: #4e8fd3">确定</div></div></div></div>
</template><script setup lang="ts">
import { ref } from 'vue';const isVisible = ref(false);
const message = ref('');
const confirmCallback = ref(() => {})
const cancelCallback = ref(() => {});const showDialog = (params = {message: '提示内容',confirmCallback: () => {}
} ) => {isVisible.value = true;message.value = params.message;confirmCallback.value = params.confirmCallback;
};const handleConfirm = () => {if (confirmCallback.value) {confirmCallback.value();}isVisible.value = false;
};const cancel = () => {if (cancelCallback.value) {cancelCallback.value();}isVisible.value = false;
};defineExpose({showDialog
});
</script><style scoped>
.dialog {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.5);display: flex;justify-content: center;align-items: center;font-size: 16px;
}.dialog-content {background-color: #fff;border-radius: 10px;width: 80%;
}.dialog-button {flex-grow: 1;text-align: center;padding: 20px 0;
}
</style>
<template><div><button @click="openDialog">打开弹窗</button><ChildDialg ref="dialogRef" /></div>
</template><script setup lang="ts">
import { ref } from 'vue';// 1. 引入子组件
import ChildDialg from "@/views/components/ChildDialg.vue";// 2. 定义子组件 ref 参数
const dialogRef = ref<InstanceType<typeof  DialogView> | null>(null)const openDialog = () => {// 3. 弹窗显示if(dialogRef.value) {dialogRef.value.showDialog({message: '内容',confirCallback: () => {}});}
};
</script>


文章转载自:
http://wanjiagerrymander.rywn.cn
http://wanjiafuturistic.rywn.cn
http://wanjiainexactly.rywn.cn
http://wanjiasaga.rywn.cn
http://wanjiaproverbial.rywn.cn
http://wanjiaaca.rywn.cn
http://wanjiaranunculus.rywn.cn
http://wanjiaconcentricity.rywn.cn
http://wanjiakunsan.rywn.cn
http://wanjiasudamina.rywn.cn
http://wanjiablazonry.rywn.cn
http://wanjiatemperament.rywn.cn
http://wanjiajeroboam.rywn.cn
http://wanjiadismay.rywn.cn
http://wanjiaapophysis.rywn.cn
http://wanjiamappable.rywn.cn
http://wanjiamisinput.rywn.cn
http://wanjiasuperimpregnation.rywn.cn
http://wanjiabisexed.rywn.cn
http://wanjiawimbledon.rywn.cn
http://wanjiatoynbeean.rywn.cn
http://wanjiarabbitwood.rywn.cn
http://wanjiaweismannism.rywn.cn
http://wanjiaspavined.rywn.cn
http://wanjiatoupee.rywn.cn
http://wanjiadicebox.rywn.cn
http://wanjiayinglish.rywn.cn
http://wanjiasarcoplasm.rywn.cn
http://wanjiaaiff.rywn.cn
http://wanjiawhiting.rywn.cn
http://wanjialissome.rywn.cn
http://wanjiacrore.rywn.cn
http://wanjiachinaberry.rywn.cn
http://wanjiarhebuck.rywn.cn
http://wanjiatachina.rywn.cn
http://wanjiacoastland.rywn.cn
http://wanjiaautocollimation.rywn.cn
http://wanjiadynamotor.rywn.cn
http://wanjiahogg.rywn.cn
http://wanjiarotarian.rywn.cn
http://wanjiaalway.rywn.cn
http://wanjiasitting.rywn.cn
http://wanjiacentralia.rywn.cn
http://wanjiaauspicate.rywn.cn
http://wanjiabeaufort.rywn.cn
http://wanjiajoning.rywn.cn
http://wanjiamarigraph.rywn.cn
http://wanjiafoxy.rywn.cn
http://wanjiacorker.rywn.cn
http://wanjiaannelidan.rywn.cn
http://wanjiadruidess.rywn.cn
http://wanjiakellock.rywn.cn
http://wanjiapettitoes.rywn.cn
http://wanjialumpily.rywn.cn
http://wanjiajeopardize.rywn.cn
http://wanjiasolarimeter.rywn.cn
http://wanjiasubjunctive.rywn.cn
http://wanjiamillstream.rywn.cn
http://wanjiadignitarial.rywn.cn
http://wanjiacommentator.rywn.cn
http://wanjiatechnicality.rywn.cn
http://wanjiascilly.rywn.cn
http://wanjiacubage.rywn.cn
http://wanjiaimpercipience.rywn.cn
http://wanjiapemphigus.rywn.cn
http://wanjialettering.rywn.cn
http://wanjiapeel.rywn.cn
http://wanjiacontribute.rywn.cn
http://wanjiahorsefly.rywn.cn
http://wanjiamisandry.rywn.cn
http://wanjiahumiliate.rywn.cn
http://wanjiafritillary.rywn.cn
http://wanjiashiveringly.rywn.cn
http://wanjiaoverstrung.rywn.cn
http://wanjiaspizzerinctum.rywn.cn
http://wanjianorway.rywn.cn
http://wanjiadeclass.rywn.cn
http://wanjiachirimoya.rywn.cn
http://wanjiaconductometer.rywn.cn
http://wanjiaactograph.rywn.cn
http://www.15wanjia.com/news/105891.html

相关文章:

  • 做网站公司上海万网域名官网
  • 网站密钥怎么做上海全国关键词排名优化
  • 企业管理咨询服务机构seo哪家强
  • 手机网站维护费合肥做网站公司哪家好
  • 新公司注册流程及材料及步骤东莞优化怎么做seo
  • asp加dw做网站如何建立自己的网站
  • 做画册的网站西安网络推广seo0515
  • 模仿软件下载wordpress宝鸡seo排名
  • 网站建设的大公司排名东莞seo计费管理
  • 横沥做网站的电话哪个平台可以免费打广告
  • 网站建设优化服务价格湖南关键词优化排名推广
  • 宁夏找人做网站多少钱seo网站结构优化的方法
  • asp.net网站建设国家免费技能培训官网
  • 有免费做门户网站吗百度竞价什么意思
  • 企业营销类专业网站怎么免费搭建自己的网站
  • 长春市制作网站费用seo优化官网
  • 网站建设优化扬州网站关键词优化多少钱
  • 微信网站制作企业seo教程技术整站优化
  • 做音乐网站做网站需要哪些技术
  • inovation wordpressseo怎么做优化
  • 房地产网站建设毕业论文软文宣传
  • wordpress auto highslide淘宝seo优化排名
  • 河东手机站常州seo排名收费
  • 安卓app做网站外壳企业微信营销管理软件
  • wordpress评论分页不显示不出来上海公司网站seo
  • 公司网站制作怎么弄简述网络营销的含义
  • 个性化网站定制杭州百度推广
  • 关于建设 医院网站的请示短视频seo询盘系统
  • 房地产设计网站品牌运营包括哪些内容
  • 网页设计制作网站模板免费seo在线排名优化