摘要: 用库pubsub-js库 一、在终端安装库,命令 npm i pubsub-js 二、 在需要接受消息的组件导入库 import pubsub from 'pubsub-js' mounted(){ this.pubid=pubsub.subscribe('hello',function(_,dat 阅读全文
posted @ 2021-12-17 20:51 浩鑫 阅读(86) 评论(0) 推荐(0)
摘要: 一、安装全局事件总线: 首先在main.js中要定一个x,$bus作为数据中转中心 new vue({ beforCreate(){ this.prototype.$bus=this }) 二、在School.vue中注册一个事件: mounted(){ this.$bus.$on('hello', 阅读全文
posted @ 2021-12-17 20:10 浩鑫 阅读(85) 评论(0) 推荐(0)