1.bus.js文件: assets目录下
import Vue from ‘vue‘ // 创建通讯实例 var bus = new Vue() export default bus
2.在需要通讯的页面引入:
import Bus from ‘@/assets/common/bus‘
3.在数据发起方发送:
Bus.$emit(‘getCode‘,this.openDialog1.groupid)
4.数据接收方获取:mounted里
Bus.$on(‘getCode‘, function (msg) { // 获取小助手列表 var param = new FormData() param.append(‘groupid‘, msg) _PhPApi.getGroupInfo(param) .then(res => { this.tableData = res.data.assistantInfo }) }.bind(this))
原文地址:https://www.cnblogs.com/rockyan/p/10451194.html
时间: 2024-10-08 23:20:09