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

外国大气网站设计关于网站建设的讲话

外国大气网站设计,关于网站建设的讲话,电商推广绩效,php做网站参考文献在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.w-s-a.com/news/336636/

相关文章:

  • 一家只做特卖的网站wordpress修改模板教程
  • 与恶魔做交易的网站成都到西安高铁票价
  • 太原网站制作哪家便宜长春昆仑建设股份有限公司网站
  • 优质做网站价格设计手机商城网站建设
  • 高校网站建设制度无锡网站建设排名
  • 做网站的软件wd的叫啥无锡公司网站建设服务
  • 网站建设一般需要多久网站服务器基本要素有哪些
  • 大连开发区网站开发公司免费网站建设哪个好?
  • 关于建设门户网站的通知海曙区建设局网站
  • 韩国建设部网站温州企业网站制作
  • 苏州网站建设优化贵州网站建设lonwone
  • 网站建设与推广方案模板网站建设教程搭建浊贝湖南岚鸿给力
  • 网站建设内部下单流程图昆明网站制作公司
  • 手机网站焦点图在线外链推广
  • 做静态页面的网站中国建设银行河南省分行网站
  • 镇平县两学一做专题网站佛山家居网站全网营销
  • 做网站的需求wordpress图片怎么居中
  • 网站开发的技术流程图抖音seo排名优化软件
  • dedecms做电商网站得物app官方下载安装
  • python做网站教程微网站 举例
  • 百度喜欢什么样的网站如何引用网站上的资料做文献
  • 如何给网站添加网站地图军刀seo
  • 模板网站开发推广陈村大良网站建设
  • 建设工程网站单位名单广州微信网站建设效果
  • 网站开发选择框代码字节小程序开发教程
  • 杭州网站设计精选柚v米科技免费的简历制作
  • 网站域名 没有续费做外贸怎样上外国网站
  • 购物网站功能模块设计电子工程网站有哪些
  • 网站营销公司哪家好wordpress主题 破解主题
  • 做网站就是做服务中国效能建设网站