在路由中添加了和當(dāng)前路由相同的路由吼蚁,就會(huì)報(bào)錯(cuò):Navigating to current location (xxx) is not allowed
解決方法:在router.js頁(yè)面:
import Router from 'vue-router'
// 重寫路由的push方法--->這個(gè)是vue-cli4.x以上的坑
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
return routerPush.call(this, location).catch(error => error)
}