简体   繁体   English

Vue Router:嵌套的动态路由

[英]Vue Router: Nested Dynamic Routes

Wassup Guys, Wassup伙计们,

Currently I am working on the vue-router together with the Vuex Store.目前我正在与 Vuex Store 一起开发 vue-router。 However, I have a route, that contains two dynamic parameters (:id, :templateId).但是,我有一条路线,其中包含两个动态参数(:id,:templateId)。

My Question is, what I need to define in my routes, in order to use this nested dynamic url.我的问题是,我需要在我的路线中定义什么,才能使用这个嵌套的动态 url。 Normally I just a level one route.通常我只是一级路线。

index.ts索引.ts


const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    // as of now there are no public and private routes
    redirect: '/login',
  },
  {
    path: '/login',
    component: LoginField,
  },
  {
    path: '/features',
    component: FeaturePage,
    children: [
      {path: ':id', component: FeaturePage, props: true}
    ]
  },
  {
    path: '/features/:id/template/:templateId',
    component: TemplatePage,
  },
  {
    path: '/notFound(.*)',
    redirect: '/features',
  },
  
];

try this尝试这个

 {
  path: "/features/:id",
  component: FeaturePage, // FeaturePage should route-view to contain child router
  children: [
     // FeaturePage should route-view to contain child router
     // it is a infinite loop 
     // dont use FeaturePage in this route
    // { path: "", component: FeaturePage, props: true },
    { path: "other-path/:prop", component: OtherPage, props: true },
    {
      path: "template/:templateId",
      component: TemplatePage,
      props: true,
    },
  ],
}

demo in codepen在 codepen 中演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM