Vue js:如何在 url 中获取特定的路由参数

Vue js : How to get specific route parameter in url

我有一个嵌套的路由设置

let routes = [
{
    name: 'Admin',
    path: '/prod/:id',
    component: Admin,
    meta: {
        requiresAuth: true,
        title: 'Admin - Fraud tool'
    },
    children:[
        {
            path: 'users',
            component: Users
        }
    ]
}];

那我的url是这样的

http://localhost/prod/admin/users

如何在 vue js 中获取此路由中的 admin

试试这个 $route.params.id$route.params 会给你对象结果

https://jsfiddle.net/yyx990803/L7hscd8h/

https://router.vuejs.org/guide/essentials/dynamic-matching.html