鍍金池/ 問(wèn)答/HTML/ 關(guān)于vue中router-link點(diǎn)擊跳轉(zhuǎn)問(wèn)題?

關(guān)于vue中router-link點(diǎn)擊跳轉(zhuǎn)問(wèn)題?

第一次點(diǎn)擊的時(shí)候路由是這樣http://localhost:8080/apple/red/detail/3

當(dāng)我在跳轉(zhuǎn)的頁(yè)面中多次點(diǎn)擊,路由會(huì)累加在后面,http://localhost:8080/apple/red/detail/apple/red/detail/apple/red/detail/apple/red/detail/3

這是為什么?

<router-link :to="{path:'apple/red/detail/3'}">to apple</router-link>
mode:'history',
routes: [

{
  path: '/',
  name: 'HelloWorld',
  component: HelloWorld
},
{
    path:'/apple/:color/detail/:type',
    
    name:'apple',
    component:Apple
}

]

回答
編輯回答
孤毒

path:'/apple/:color?/detail/:type?'這樣試試,

2017年7月11日 04:17
編輯回答
司令

是router-link中,改成{path:'/apple/red/detail/3'}

2017年10月29日 20:52