传过来的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() {
// 获取传递过来的id
this.id = this.$route.params.id
//跳转到路由3
this.$router.push("/page3");
},
路由3是路由2的子路由