美文网首页
vue项目:Navigating to current loca

vue项目:Navigating to current loca

作者: 尤雨溪的大迷弟 | 来源:发表于2020-01-07 15:51 被阅读0次

在路由中添加了和当前路由相同的路由,就会报错:Navigating to current location (xxx) is not allowed
解决方法:在router.js页面:

import Router from 'vue-router'
//  重写路由的push方法--->这个是vue-cli4.x以上的坑
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}

相关文章

网友评论

      本文标题:vue项目:Navigating to current loca

      本文链接:https://www.haomeiwen.com/subject/cgrunctx.html