vue-router点击相同的路由链接会报错NavigationDuplicated
{
"_name": "NavigationDuplicated",
"name": "NavigationDuplicated",
"message": "Navigating to current location (\"/createAvt\") is not allowed"
}
在router文件中添加
import Router from 'vue-router'
// Router 是import导入的路由
// 获取原型对象push函数
const originalPush = Router.prototype.push
// 获取原型对象replace函数
const originalReplace = Router.prototype.replace
// 修改原型对象中的push函数
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
// 修改原型对象中的replace函数
Router.prototype.replace = function replace(location) {
return originalReplace.call(this, location).catch(err => err)
}
标签:vue,err,router3,replace,NavigationDuplicated,报错,location,push,Router
From: https://www.cnblogs.com/jia-zq/p/16996993.html