- vue路由报错:
Uncaught (in promise) Error: Avoided redundant navigation to current location- 原因:
多次点击跳转同一个路由是不被允许的- 解决办法:
在引入vue-router的js文件里加上如下代码即可:
//push
const VueRouterPush = Router.prototype.push
Router.prototype.push = function push (to) {
return VueRouterPush.call(this, to).catch(err => err)
}
//replace
const VueRouterReplace = Router.prototype.replace
Router.prototype.replace = function replace (to) {
return VueRouterReplace.call(this, to).catch(err => err)
}
本文介绍了在使用Vue.js进行Web应用开发时遇到的一个常见问题:重复导航到当前路由位置导致的错误。提供了通过覆盖Vue-router中push和replace方法来避免此错误的具体实现方式。
1万+

被折叠的 条评论
为什么被折叠?



