【发布时间】:2020-05-01 20:12:59
【问题描述】:
是否可以将当前登录用户的 id 传递给路由器链接的params?
这是我当前的代码,我想在基于params id的页面中呈现信息
routes.js
{
path: '/objective/employee/:id',
name: 'employee-objective',
component: () => import('@/views/EmployeeObjective'),
meta: { requiresAuth: true }
},
Component.vue
created () {
this.$store.dispatch('authUserInformation')
},
computed: {
loggedIn () {
return this.$store.getters.loggedIn
},
authUser () {
return this.$store.state.authUser
}
}
路由器链接
<router-link :to="{ name: 'employee-objective',
params: {
id: // this.$store.state.authUser <- does not work
// authUser[0].id <- does not also work
}}">
Click Here
</router-link>
【问题讨论】:
-
我认为问题出在你的路由器链接
-
<router-link :to="{ name: 'employee-objective', params: { id: $store.state.authUser }}">
标签: vue.js vuex vue-router