A页面点击箭头跳转到B页面
页面B点击箭头返回上一页
从B页面返回后的页面A (回到了第一个tab,应该回到第三个)
路由的meta中添加keepAlive:true
{
path: "/ms-calendar",
name: "ms-calendar",
component: () => import("@/pages/micro-station/ms-calendar.vue"),
meta: {
keepAlive:true,
},
},
在js中添加以下代码
// 返回上一页路由不刷新问题
beforeRouteLeave(to, from, next) {
// /A为A页面路由
if (to.path == '/A') {
to.meta.keepAlive = true;
} else {
to.meta.keepAlive = false;
}
next();
},
添加代码后从B页面返回的A页面定位在跳转页面时的tab