|
@@ -216,10 +216,25 @@ const router = new Router({
|
|
|
// //如果存在用户账号信息|| to.query.uid
|
|
|
// next();
|
|
|
// })
|
|
|
-// //同一个路由跳转报错解决,NavigationDuplicated: Avoided redundant navigation to current location:
|
|
|
-// const originalPush = Router.prototype.push
|
|
|
-// Router.prototype.push = function push(location) {
|
|
|
-// return originalPush.call(this,location).catch(err=>err)
|
|
|
-// }
|
|
|
+// 添加路由守卫
|
|
|
+router.beforeEach((to, from, next) => {
|
|
|
+ // 如果目标路由是webgl_rxdz_test
|
|
|
+ if (to.name === 'webgl_rxdz_test') {
|
|
|
+ // 如果来源是webgl_rxdz_test_houseList,设置keepAlive为false
|
|
|
+ if (from.name === 'webgl_rxdz_test_houseList') {
|
|
|
+ to.meta.keepAlive = false;
|
|
|
+ } else {
|
|
|
+ // 其他来源保持默认的keepAlive为true
|
|
|
+ to.meta.keepAlive = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ next();
|
|
|
+});
|
|
|
+
|
|
|
+// 解决路由重复导航的问题
|
|
|
+const originalPush = Router.prototype.push;
|
|
|
+Router.prototype.push = function push(location) {
|
|
|
+ return originalPush.call(this, location).catch(err => err);
|
|
|
+}
|
|
|
|
|
|
export default router;
|