1. 程式人生 > 其它 >VUE Tabbar重複點選報錯問題

VUE Tabbar重複點選報錯問題

技術標籤:vueVueRouter

Tabbar重複點選報錯問題

問題: 當我們重複點選底部導航是控制檯回報錯
tabbar

報錯:

解決方法:router.js加以下程式碼

//router.push方法
  const originalPush = VueRouter.prototype.push;
  VueRouter.prototype.push = function(location) {
    return originalPush.call(this, location).catch(err => err);
  };
  
//router.replace方法
  const
originalReplace = VueRouter.prototype.replace; VueRouter.prototype.replace = function replace(location) { return originalReplace.call(this, location).catch(err => err); }