美文网首页
解决Vue中的NavigationDuplicated 报错

解决Vue中的NavigationDuplicated 报错

作者: 前端新阳 | 来源:发表于2019-12-02 22:40 被阅读0次
    • 最近遇到一个这样的问题: 在当前页面点击导航跳转当前页面,跳转方法用的是 this.$router.push({ name }); ,跳转其他页面是可以的,跳转当前页面会报这样的错误,但不影响使用!

    • 解决方法:在引用vue-router的文件中添加如下代码:

    const originalPush = Router.prototype.push;
    Router.prototype.push = function push(location) {
        return originalPush.call(this, location).catch(err => err);
    };
    
    image.png

    相关文章

      网友评论

          本文标题:解决Vue中的NavigationDuplicated 报错

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