Vue 解决项目中重复点击相同路由报错问题

报错内容
vue-router.esm.js?8c4f:2089 Uncaught (in promise) NavigationDuplicated {_name: “NavigationDuplicated”, name: “NavigationDuplicated”, message: “Navigating to current location (”/changePassword") is not allowed", stack: “Error↵ at new NavigationDuplicated (webpack-int…node_modules/vue/dist/vue.runtime.esm.js:1853:26)”}
在这里插入图片描述

解决方法:

在mian.js中添加如下代码片段

import Router from 'vue-router'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    
    
  return originalPush.call(this, location).catch(err => err)
}

猜你喜欢

转载自blog.csdn.net/oilpastell/article/details/108075596