在使用vue构建项目的时候为了控制页面刷新后路由和界面保持在原来的位置
加了
reloadRouter(path) {
this.$router.replace({
path: path,
query: {
nextPath: path
}
});
}
当这么做的时候 页面的浏览地址就会出现两个同样的路由地址
然后想着去掉一个就把nextPath
包括nextPath
后面的都删掉
出现
Navigating to current location ("/xxxx") is not allowed
的红色警告
使用catch 处理红色警告
页面就正常了
如果有碰到类似问题的同学有更好的解决办法 可以交流一下 非常感谢
reloadRouter(path) {
this.$router.replace({
path
}).catch(error=> error);
}