import Vue from 'vue' //导入vue文件
import VueRouter from 'vue-router' //导入vue-router文件(前提要安装vue-router!!!)
Vue.use(VueRouter)
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
// 避免重复点击路由报错
//如果是push方法报错就导入这个
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
//如果是replace方法报错就导入这个
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
return originalReplace.call(this, location).catch(err => err)
}