場景:
pageA----pageB(pageB包含三個二級路由)
默認進入pageB時進入第一個頁面的路由,之后點擊左側按鈕,分別進入其他二級路由
原router.js寫法:
//應用信息
{
path:'/app-manage',
name:'app-manage',
component:AppManage,
redirect:'/app-manage/appMsg',
children:[
//應用信息
{
path:'/app-manage/appMsg',
name:'appMsg',
component:AppMsg,
},
...其他子路由...
]
},
頁面路由跳轉寫法:
<router-link class="lis" tag="li" v-for="(item,index) in side" :to="{path:item.url,query:{appMsg}}" :key="index">
{{item.name}}
</router-link>
問題,一次進入默認路由時,不傳遞參數,只有在之后的點擊第一個路由時才傳遞
解決方法:
1.去除router.js的redirect屬性
2.在pageB頁面第一次頁面加載請求到數據后添加
let appMsg = this.appMsg
this.$router.push({path:'/app-manage/appMsg',query:{appMsg}})