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)
};

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章