首页 >> js开发 >> jsVue-router 报错NavigationDuplicated的解决方法js大全
jsVue-router 报错NavigationDuplicated的解决方法js大全
发布时间: 2021年1月13日 | 浏览:
| 分类:js开发
版本:3.1.x版本: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)
}
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)
this.$router
.replace(this.path)
.catch(err => err) 说明:第一种方法好像对replace()没有作用。
报错原因:使用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)
}
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)
this.$router
.replace(this.path)
.catch(err => err) 说明:第一种方法好像对replace()没有作用。
相关文章:
- js解决vue+router路由跳转不起作用的一项原因js大全
- js解决echarts中横坐标值显示不全(自动隐藏)问题js大全
- js使用 Github Actions 自动部署 Angular 应用到 Github Pages的方法js大全
- jsmpvue 项目初始化及实现授权登录的实现方法js大全
- js一文读懂vue动态属性数据绑定(v-bind指令)js大全
- jsVue清除定时器setInterval优化方案分享js大全
- js解决elementUI 切换tab后 el_table 固定列下方多了一条线问题js大全
- js如何实现echarts markline标签名显示自己想要的js大全
- js详细分析vue表单数据的绑定js大全
- js代码基于VSCode调试网页JavaScript代码过程详解