Vue Router Child, Trailing slash

北城余情 提交于 2019-12-08 04:53:16

问题


Is is it normal behavior for Vue to add a trailing slash to the default child subroute?

For example:

URL

Result:
/#/user/test/

Link

<router-link :to="{ name: 'user', params: { username: 'test' } }">Test User Overview</router-link>

Routes

routes: [
     {
        path: '/user/:username',
        component: User,
        children: [
            {
                path: '',
                name: 'user',
                component: UserOverview
            },
            {
                path: 'stats',
                name: 'user.stats',
                component: UserStats
            }
        ]
    }
]

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?


回答1:


Yes, it is. And do not try to prevent this behaviour, it is preferred and recommended.

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



来源:https://stackoverflow.com/questions/47350259/vue-router-child-trailing-slash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!