問題:最近在項目中,做左側菜單欄時,發現點擊路由跳轉相同地址 會有這個報錯
Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}
解決辦法:
router.js(或者router文件夾下index.js)中,添加這段代碼
import Router from 'vue-router';
Vue.use(Router)
// 添加這下面一段代碼,就可以解決報錯
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
};