vue路由中 Navigating to current location ("/xxx") is not allowed

原因:报错原因:多次点击同一路由,导致路由被多次添加

解决:在引入路由的地方

import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
//重写router的push方法

  const VueRouterPush = router.prototype.push

  router.prototype.push = function push (to) {

    return VueRouterPush.call(this, to).catch(err => err)

  }

posted @ 2020-04-22 15:10  J__F  阅读(401)  评论(0编辑  收藏  举报