美文网首页
解决EventBus可以传值无法渲染

解决EventBus可以传值无法渲染

作者: 老Daaa | 来源:发表于2020-07-03 17:45 被阅读0次

A页面

EventBus.$emit("postMobilesStr",data)

B页面

data里面重新定义一个值,用EventBus代替this

data(){
    return {
        str:""
    }
}
EventBus.$on("postMobilesStr", ({ mobilesStr }) => {
    //用EventBus代替this
    EventBus.str = mobilesStr
 });

相关文章

网友评论

      本文标题:解决EventBus可以传值无法渲染

      本文链接:https://www.haomeiwen.com/subject/qgxeqktx.html