鍍金池/ 問答/HTML/ vue 子路由的參數(shù)覆蓋父路由攜帶的參數(shù)

vue 子路由的參數(shù)覆蓋父路由攜帶的參數(shù)

我的父路由本身要攜帶參數(shù) aa
但是里面的子路由也要攜帶參數(shù)bb 但是路徑中的aa就會不見
http://localhost:8080/#/index/1 (1是aa)這個地址會有一個頁面 然后在這個里面有一個子路由跳轉(zhuǎn) 我想要的是 http://localhost:8080/#/index/1/12 (1是aa 12是bb)
但是每次點(diǎn)擊他跳轉(zhuǎn)的都是 http://localhost:8080/#/index/12
每次父路由里的參數(shù)aa都沒有了
這是為什么呀?

點(diǎn)擊跳轉(zhuǎn)代碼:

<router-link :to="item.bb" >{{item.name}}</router-link>

路由:

{
      path: '/index/:aa',
      name: 'index',
      component: index,
      children:[
        {path:'bb',name:'detail',component:detail},
      ]
    },

然后我有嘗試加在<router-link>里面加append 但是第一次是可以的 我再點(diǎn)別的分類就會不對了

回答
編輯回答
檸檬藍(lán)

aa需要動態(tài)添加
<router-link :to="/index/demo" >{{item.name}}</router-link>
此時的demo就相當(dāng)于aa
<router-link :to="/index/:aa" >{{item.name}}</router-link>

況且aa 是這樣取的this.$route.params.aa

{

  path: '/index/:aa',
  name: 'index',
  component: index,
  children:[
    {path:'bb',name:'detail',component:detail},
  ]
},

這里的name,component是這樣取的 this.$route.query.name ,this.$route.query.component

所以 ‘vue 子路由的參數(shù)覆蓋父路由攜帶的參數(shù) ’
這個問題本身就是不存在的

2017年4月5日 17:56