首页 > 其他 > 详细

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location:

时间:2021-06-21 11:34:50      阅读:69      评论:0      收藏:0      [点我收藏+]

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “/users”. 关于这个报错的原因和解决方案如下:

技术分享图片

 

 

原因: 源码 install 安装依赖时,Router(路由版本不一致) 也可以修改 package.json 里面的 Router 版本

解决方案:在router文件夹下的index.js中加入如下代码

 const originalPush = Router.prototype.push
 Router.prototype.push = function push(location) {
 return originalPush.call(this, location).catch(err => err)
 }

index.js中完整的代码如下:

import Vue from vue
import Router from vue-router
import Index from "../components/Index";
import List from "../components/users/List";

Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
 return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {path: /, redirect:/index},
    {path:/index, name:Index, component:Index},/*这里的ecomponent后便容易多一个s*/
    {path: /users, component: List},
    // {path: ‘‘,component: }
  ]
})

 

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location:

原文:https://www.cnblogs.com/qianxiaoPro/p/14911477.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!