Vue-router 报错NavigationDuplicated的解决方法
2020-04-01 07:06
1021 查看
版本:3.1.x
报错原因:
使用push()、replace()进行导航时,不能重复导航到当前路由。
解决办法:
方法1:在定义路由的文件中router/index.js
const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push (location) { return originalPush.call(this, location).catch(err => err) } const originalReplace = VueRouter.prototype.replace VueRouter.prototype.repalce = function replace (location) { return originalReplace.call(this, location).catch(err => err) }
方法2:在调用push()、replace()方法时,catch
this.$router .replace(this.path) .catch(err => err)
说明:第一种方法好像对replace()没有作用。
到此这篇关于Vue-router 报错NavigationDuplicated的解决方法的文章就介绍到这了,更多相关Vue-router 报错NavigationDuplicated内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章:
相关文章推荐
- vue-router 多个路由地址绑定一个组件造成 created 不执行的解决方法
- vue-router 多个路由地址绑定一个组件造成 created 不执行的解决方法
- vue-cli 解决跨域 proxyTable设置无效 报错504--- 解决方法
- vue项目加了vue-router懒加载,打包后在服务器上访问,报错Loading chunk 40 failed. 解决办法
- Vue-router本地服务器使用history出现找不到页面的问题解决方法
- vue2.0 路由不显示router-view的解决方法
- vue-router路由参数刷新消失的问题解决方法
- vue-router 中router-view不能渲染的解决方法
- 解决element-ui中el-menu组件作为vue-router模式在刷新页面后default-active属性与当前路由页面不一致问题的方法
- vue-router懒加载速度缓慢问题及解决方法
- vue中各种报错的解决方法
- 使用vue-router与v-if实现tab切换遇到的问题及解决方法
- 记录【1】Vue遇到的bug , 点击按钮出现Cannot read property 'toString' of undefined的解决方法
- Application Loader 上传报错ITMS-90087,ITMS-90209,ITMS-90125,解决方法
- vue 编程式导航 router.push() 方法使用
- vue使用element-ui的el-input监听不了回车事件的解决方法
- vue.js开发SPA常见问题及解决方法
- adb install 报错INSTALL_FAILED_UPDATE_INCOMPATIBLE 解决方法
- 解决Nginx出现403 forbidden (13: Permission denied)报错的四种方法
- ORACLE11G在LINUX6下安装及报错 C [ld-linux-x86-64.so.2+0x14d70]的解决方法