我正在用Vue 2和Vuetify创建一个测试Progressive Web App。我有这个
routes: [
{
path: '/',
name: 'login',
component: Login
},
{
path: '/users',
name: 'users',
component: Users
},
{
path: '/create',
name: 'create',
component: Create
},
{
path: '/edit/:id?',
name: 'edit',
component: Edit
}
]
在侧边栏我有路线去用户列表和创建新用户。假设在用户列表中,我点击编辑用户,所以我输入编辑/ 1路线。当我打开侧边栏并点击显示用户列表去编辑/用户。显然这条路线是错误的,因为显示所有用户是/用户。显然,编辑路线添加其他路线作为参数。
那么,路线有什么问题?
发布于 2018-06-25 13:05:37
如果我不得不猜测,你的链接看起来像
<router-link to="users">Users</router-link>
在to
道具中使用字符串时,将其视为路径。如果没有正斜杠前缀,它是一个相对路径。
鉴于你已经命名了所有的路线,你可以确保你的导航使用路线名称去正确的路线名称
<router-link :to="{name: 'users'}">Users</router-link>
https://stackoverflow.com/questions/-100005503
复制相似问题