菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
377
0

解决vue项目路由出现message: "Navigating to current location (XXX) is not allowed"的问题(点击多次跳转)

原创
05/13 14:22
阅读数 47909

如果网页跳转用的方法传参去跳转: (点击多次链接会出现错误)

<a class="" href="javascript:void(0);" @click="goto('M000989')">跳转</a>

 

    goto: function(mallCode){
      this.$router.push({
        path: '/about',
        //name: 'about',
        query: {
          mallCode: 'M000989'
        }
      })
    },

 

 

这个的原因: 

原因:在路由中添加了相同的路由。
解决:
重写路由的push方法

在src/router/index.js 里面import Router from 'vue-router'下面写入下面方法即可

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

 

 

 

 

转 : https://www.cnblogs.com/lxk0301/p/11671256.html

 

发表评论

0/200
377 点赞
0 评论
收藏
为你推荐 换一批