默认路由器:使 id 持久化到所有 children

Default router: make id persist to all children

我想要一个 id 来坚持所有路线。

例如www.website.com/#/:id/routes

我已尝试执行以下操作:

export default new Router({
    routes: [
        {
            path: '/:id/',
            props: true,
            component: FirstView,
            children: [
                {
                    path: '/',
                    name: 'Second',
                    component: SecondView
                }
            ]
        }
    ]
});

但我无法让 :id 坚持下去。有什么想法吗?

您已将嵌套路由路径指定为 /,这使得路由器将其视为根路径,而不是在父路由中使用 /:id 作为前缀。

Here's a simple demonstration of nesting routes.