项目场景:
商城app导航切换
问题描述
重复点击导航出现报错
原因分析:
NavigationDuplicated
解决方案:
在router.js或router文件夹下的index.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)
}