vue router 嵌套、父子、多个路由跳转传值获取不到参数undefined
生活随笔
收集整理的這篇文章主要介紹了
vue router 嵌套、父子、多个路由跳转传值获取不到参数undefined
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
傳過來的id是undefined
解決方法
在router.js里面取消重定向到路由3,在路由2里面使用編程式導航跳轉
{path: '/page1',name: 'page1',component: Page1,children: [{path: '/page2',component: Page2,//redirect: '/page3',children: [{path: '/page3',component: Page3,},],},],},路由1
<router-link :to="{ name: 'Page2', params: { id: scope.row.id } }">傳id給并跳轉到路由2</router-link>路由2先獲取傳遞過來的id,讓后使用編程式導航跳轉到路由3
mounted() {// 獲取傳遞過來的idthis.id = this.$route.params.id//跳轉到路由3this.$router.push("/page3"); },路由3是路由2的子路由
總結
以上是生活随笔為你收集整理的vue router 嵌套、父子、多个路由跳转传值获取不到参数undefined的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: thinkpad l470 一种键盘错乱
- 下一篇: vue使用echarts图表渲染异常本地