关于当前用户有两个路由,一个是基本信息修改,一个是修改密码,都挂在/profile下面:
{
path: '/profile',
component: Layout,
hidden: true,
children: [{ path: 'main', name: '', component: userProfile },
{ path: 'change_password', name: '', component: changePassword }]
},
在这两个vue组件中,都是同样的方式访问store中的user id和name:
computed: {
...mapGetters([
'user_id',
'username',
'token'
])
},
在userProfile组件的created中console.log打印this.user_id,this.username正常,但是在changePassword组件的created中打印就报异常:
vue.esm.js?efeb:574 [Vue warn]: Error in created hook: "InvalidTokenError: Invalid token specified"
found in
---> <ChangePassword> at src/views/user_profile/changePassword.vue
<AppMain> at src/views/layout/AppMain.vue
<Layout> at src/views/layout/Layout.vue
<App> at src/App.vue
<Root>
这里应该不是vuex的问题,是语法错误,好好查看语法有没有错误