欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue路由跳轉(zhuǎn)問題記錄詳解

 更新時(shí)間:2017年06月15日 11:35:27   作者:梁少豪  
本篇文章主要介紹了Vue路由跳轉(zhuǎn)問題記錄詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

最近項(xiàng)目上需要用Vue用來做app,在Vue中使用路由時(shí)遇到下面的問題。

路由設(shè)置如下:

{

path:'/tab',

component:Tab,

children:[{

path:'layoutList',

name:'LayoutList',

component:LayoutList

},{

path:'layoutView/:layoutId',

name:'LayoutView',

component:LayoutView

},{

path:'layoutDetail/:viewId',

name:'LayoutDetail',

component:LayoutDetail

}]

}

其中/tab是根地址,有3個(gè)子地址,3個(gè)子地址層級為:LayoutList => LayoutView => LayoutDetail

正常情況:假設(shè)當(dāng)前路由為/tab/layoutList,需要跳轉(zhuǎn)到LayoutView頁面,可以通過router.push({path:'layoutView/'+item.id})

跳轉(zhuǎn)后的路由為/tab/layoutView/1

 

    

當(dāng)我想從LayoutView頁面跳轉(zhuǎn)到對應(yīng)的LayoutDetail頁面時(shí):

情況一:(找不到頁面)

跳轉(zhuǎn)前地址:/tab/layoutView/1

跳轉(zhuǎn)代碼:router.push({path:'layoutDetail/'+item.id});

跳轉(zhuǎn)后地址:/tab/layoutView/layoutDetail/27

情況二:(找不到頁面)

跳轉(zhuǎn)前地址:/tab/layoutView/1

跳轉(zhuǎn)代碼:router.push({path:'/layoutDetail/'+item.id});

跳轉(zhuǎn)后地址:/layoutDetail/27

情況三:(找不到頁面)

跳轉(zhuǎn)前地址:/tab/layoutView/1

跳轉(zhuǎn)代碼:router.push({path:'tab/layoutDetail/'+item.id});

跳轉(zhuǎn)后地址:/tab/layoutView/tab/layoutDetail/27

情況四:(頁面正常顯示)

跳轉(zhuǎn)前地址:/tab/layoutView/1

跳轉(zhuǎn)代碼:router.push({path:'/tab/layoutDetail/'+item.id});

跳轉(zhuǎn)后地址:/tab/layoutDetail/27

只有按照情況四的操作,才能正常顯示出來頁面。

vue路由會(huì)根據(jù)push的地址,如果地址不是/開頭,會(huì)直接替換當(dāng)前路由的最后一個(gè)/后的地址,

如果地址是/開頭,會(huì)以push的地址作為絕對地址進(jìn)行跳轉(zhuǎn)。

另外我嘗試還使用router.go({name:'LayoutDetail',params:{viewId:item.id}}),頁面不會(huì)跳轉(zhuǎn)且地址也不會(huì)改變。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論