如果页面中有要请求的数据 那么刷新之后获取不到数据是因为一开始的页面的id(id只是个例子)是由别的页面传进来的,当跳转到子路由时再刷新获取不到id
解决办法
让嵌套子路由接收query参数
{
path: "/singerpage",
component: SingerPage,
redirect: '/singerpage/hotsing',
props(route) {
return {
id: route.query.id
}
},
children: [
{
path: "hotsing", component: HotSing,
props(route) {
return {
id: route.query.id
}
}
},
{
path: 'allalbum', component: AllAlbum,
props(route) {
return {
id: route.query.id
}
}
}
]
}
之后每次刷新子路由之后就会携带id 就可以让父路由通过props获取参数 然后请求数据了