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

网站推广的技巧和方法dedecms告侵权

网站推广的技巧和方法,dedecms告侵权,网络服务商都有哪些公司,西宁市建设网站价格低在Element UI中#xff0c;如果多个父子组件共用一个el-dialog弹窗#xff0c;并且需要在切换组件页面时关闭弹窗#xff0c;你可以考虑以下方法来实现#xff1a; 使用Vuex进行状态管理#xff1a; 在Vuex中创建一个状态来管理弹窗的显示状态#xff08;例如#xff0…在Element UI中如果多个父子组件共用一个el-dialog弹窗并且需要在切换组件页面时关闭弹窗你可以考虑以下方法来实现 使用Vuex进行状态管理 在Vuex中创建一个状态来管理弹窗的显示状态例如showDialog。 在父子组件中都可以访问这个状态以便共享。 当需要打开或关闭弹窗时分发对应的Vuex mutation 来更新showDialog状态。 在el-dialog中使用v-if或v-show根据showDialog的值来控制弹窗的显示与隐藏。 // store.js import Vue from vue; import Vuex from vuex;Vue.use(Vuex);export default new Vuex.Store({state: {showDialog: false,},mutations: {toggleDialog(state) {state.showDialog !state.showDialog;},}, });在父子组件中使用 mapState 和 mapMutations 来访问和修改 showDialog 状态 // ParentComponent.vue templatedivbutton clicktoggleDialogToggle Dialog/buttonchild-component/child-componentel-dialog :visibleshowDialog closetoggleDialog!-- 弹窗内容 --/el-dialog/div /templatescript import { mapState, mapMutations } from vuex;export default {computed: {...mapState([showDialog]),},methods: {...mapMutations([toggleDialog]),}, }; /script// ChildComponent.vue templatedivbutton clicktoggleDialogToggle Dialog/button/div /templatescript import { mapMutations } from vuex;export default {methods: {...mapMutations([toggleDialog]),}, }; /script事件总线 创建一个事件总线Event Bus作为Vue实例使得不同组件可以通过该事件总线进行通信。 在需要打开或关闭弹窗的地方触发事件然后在el-dialog所在的组件中监听这些事件以控制弹窗的显示与隐藏。 // EventBus.js import Vue from vue; export default new Vue();在需要打开或关闭弹窗的地方触发事件 // ParentComponent.vue templatedivbutton clicktoggleDialogToggle Dialog/buttonchild-component/child-componentel-dialog :visibleshowDialog closetoggleDialog!-- 弹窗内容 --/el-dialog/div /templatescript import EventBus from ./EventBus;export default {data() {return {showDialog: false,};},methods: {toggleDialog() {this.showDialog !this.showDialog;EventBus.$emit(toggle-dialog, this.showDialog);},}, }; /script// ChildComponent.vue templatedivbutton clicktoggleDialogToggle Dialog/button/div /templatescript import EventBus from ./EventBus;export default {methods: {toggleDialog() {EventBus.$emit(toggle-dialog, true);},}, }; /script在el-dialog所在的组件中监听事件 // AnyComponent.vue templateel-dialog :visibleshowDialog closetoggleDialog!-- 弹窗内容 --/el-dialog /templatescript import EventBus from ./EventBus;export default {data() {return {showDialog: false,};},created() {EventBus.$on(toggle-dialog, (showDialog) {this.showDialog showDialog;});}, }; /script使用provide和inject 在父组件中使用provide来提供一个控制弹窗显示的方法或者提供一个布尔值的ref。 在子组件中使用inject来获取这些提供的数据。 子组件可以调用提供的方法或者监听提供的ref来控制弹窗的显示与隐藏。 在父组件中使用provide来提供一个方法或ref // ParentComponent.vue templatedivbutton clicktoggleDialogToggle Dialog/buttonchild-component/child-componentel-dialog :visibleshowDialog closetoggleDialog!-- 弹窗内容 --/el-dialog/div /templatescript export default {provide: {toggleDialog: this.toggleDialog, // 方法showDialogRef: this.showDialogRef, // ref},data() {return {showDialog: false,showDialogRef: ref(false),};},methods: {toggleDialog() {this.showDialog !this.showDialog;this.showDialogRef.value this.showDialog;},}, }; /script在子组件中使用inject来获取这些提供的数据 // ChildComponent.vue templatedivbutton clicktoggleDialogToggle Dialog/button/div /templatescript import { inject } from vue;export default {setup() {const { toggleDialog, showDialogRef } inject();const toggleDialogInParent () {toggleDialog();};return {toggleDialogInParent,showDialogRef,};}, }; /script
http://www.hkea.cn/news/14441672/

相关文章:

  • 母婴类网站 网站建设方案书 备案网站建设 pdf
  • 找素材的网站大全wordpress电商教程
  • 网站标识包头网站建设价格
  • 丢盖网logo在线设计泰州做网站优化
  • 网站开发作业图片网站编辑器无法显示
  • 浪漫免费表白网站live2d wordpress
  • 营销网站建设报价五家渠网站建设
  • 注销网站备案申请表做代理需要自己的网站吗
  • 做后期从哪个网站选音乐网站登记备案表
  • 网站搜索优化公司小程序助手公众平台
  • 不关闭网站备案wordpress安装上传文件
  • 自己怎么用h5做网站外贸网站功能
  • 网站建设与推广王钊做兼职去什么网站
  • 搞笑网站模板广告推广方案范文
  • 做系统网站网站怎么建设dw
  • 网站建设市场前景网站定制排名
  • 江门云建站模板国外网站源代码
  • 网站风格设计兼职网站建设策划书
  • 龙信建设集团有限公司网站共享看世界新域名
  • 合肥网站开发培训手机端网站建设要点
  • 网站流量监控网站建设分金手指专业十三
  • 昆山科技网站建设wordpress gif
  • 老外做牛排的视频网站网站设计原型图
  • 制作网站要多少钱网络托管公司有哪些
  • 如何创做网站网站企业备案资料
  • 百度官方网站网址是多少老域名重新做网站
  • 厦门怎么没有 网站备案权威的公司网站制作
  • 阿里巴巴国际站做2个网站有用吗去哪网站备案吗
  • 东莞最便宜网站建设青海 网站开发 图灵
  • 网站建设的色彩搭配网站备案后可以修改吗