vue-router中,路由子页面如何调用主页面呢,查看了官方文档,父子模块通信可以试用$on和$emit 来通信,但是到了路由里该怎么去写呢,翻遍了vue和vue-router的文档也没有找到相应的方法。官方提供的父子组件通信方法Vue.component('button-counter', { template: '<button v-on:click="increment">{{ counter }}</button>', data: function () { return { counter: 0 } }, methods: { increment: function () { this.counter += 1 this.$emit('increment') } },})new Vue({ el: '#counter-event-example', data: { total: 0 }, methods: { incrementTotal: function () { this.total += 1 } }})但是这种方法在路由里没法使用,
添加回答
举报
0/150
提交
取消