问题:当在一个导航按重复多次点击后,控制台出如下报错,原因就是路由重复添加了
解决办法:在 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)
}