vue router路由里调用vuex的方式

东明兄 2019-09-06
0条评论 1,835 次浏览
东明兄 2019-09-060条评论 1,835 次浏览

router.app 即是vue实例(vm)

vm.options.store 中就有dispatch、mutations和state、getters。

例子:


const r = new Router({ routes: [ { path: '/Login', name: 'Login', component: Login, meta: { title: '登录' } }, ] }); r.app.$options.store.commit("setMenu","菜单数据")

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注