• 解决 Vue 路由传递参数时,出现 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation 问题 .
  • 报错内容:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/search/111".
  • 问题描述:重复点击导航时,控制台报错

浏览器报错截图:

 解决方法:src/router/index.js 配置文件中添加以下代码

// src/router/index.js
import Vue from 'vue'
import VueRouter  from 'vue-router'
Vue.use(VueRouter)

//添加以下代码
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐