Vue Router Child,尾部斜杠 [英] Vue Router Child, Trailing slash
问题描述
Vue 在默认子路由中添加尾部斜杠是正常行为吗?
Is is it normal behavior for Vue to add a trailing slash to the default child subroute?
例如:
网址
Result:
/#/user/test/
链接
<router-link :to="{ name: 'user', params: { username: 'test' } }">Test User Overview</router-link>
路线
routes: [
{
path: '/user/:username',
component: User,
children: [
{
path: '',
name: 'user',
component: UserOverview
},
{
path: 'stats',
name: 'user.stats',
component: UserStats
}
]
}
]
我希望 user 链接具有由其父链接指定的路径,这意味着没有尾部斜杠.像这样:/#/user/test
.如果它是正常行为,我可以以某种方式阻止它吗?
I would expect the user link to have the path specified by its parent, meaning without a trailing slash. Like this: /#/user/test
. If its normal behavior, can I somehow prevent it?
推荐答案
是的.并且不要试图阻止这种行为,这是首选和推荐的.
Yes, it is. And do not try to prevent this behaviour, it is preferred and recommended.
在本文中阅读更多内容 - 它较旧,但并未过时:https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html?m=1
Read more in this article - it is older, but not outdated: https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html?m=1
这篇关于Vue Router Child,尾部斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!