如何通过动态路由匹配捕获更多的路径?

How to capture more of the path with dynamic route matching?

A link 从数据库中获取,例如/app/profile.

单个组件 (master/index.vue) 应呈现应用地址 (http://example.com/) 之后的任何路径。

我有以下路由器配置:

{
    path: '/',
    component: () => import('@/components/Layout.vue'),
    children: [
        {
            path: ':id',
            component: () => import('@/components/pages/master/index.vue')
        }
    ]
}

…但这没有按预期工作。它只接受 example.com 之后的一个参数。我如何让它动态工作以便它接受多个参数,例如/app/profile?

您可以使用星号来匹配 任何内容,例如:

path: '*',

如果您知道基本路径将被修复,您可以缩小匹配范围,例如/*, /app*.

请参阅全部部分下的vue-router docs on dynamic matching