组件间简单通信使用空的实例:
var app = new Vue();
然后组件1触发app.$emit:
methods: {
linkToDoing: function () { this.isToDoing = true; this.store.isToDoing = this.isToDoing; this.store.selectIndex = 0; app.$emit('store', this.store); },
} 组件2监听触发的事件app.$on:
created: function () {
app.$on('store', function (data) { this.title = data.arrTitle[data.selectIndex]; console.log('监听到了', this.title); this.store = data; });
}
最后发现能够监听到更新的数据,但是数据未渲染,请问这个如何解决?
吃鸡游戏
相关分类