vue cli3+typescript 组件通信
1.写一个bus.ts文件 把想传的值提到全局去 之后全局调用
使用bus发送数据:
bus.$emit("sendData",{data:"需要发送的数据"})
接收数据(可以写在created生命周期函数中):
bus.$on("sendData",d=>{console.log(d)})
销毁,防止全局污染:(一般写在beforeDestroy里)
bus.$of...
原创
2019-08-13 11:51:20 ·
420 阅读 ·
0 评论