vue路由 重复点击同一个路由报错 如何解决?

Element-ui 重复点击同一个路由 会报错:NavigationDuplicated {_name: “NavigationDuplicated”, name: “NavigationDuplicated”}

解决办法:

在router/index.js里重写Router.prototype.push

import Router from 'vue-router'

//需要添加的代码
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};

 


版权声明:本文为ksyjy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。