1. 程式人生 > 實用技巧 >Vue-Router在當前UR不重新整理的Debug除錯

Vue-Router在當前UR不重新整理的Debug除錯

如果使用vue-router在當前頁面重新整理,則會中斷此操作,沒有反應,錯誤資訊是:

Error: Avoided redundant navigation to current location: "/".
    at createRouterError (vue-router.esm.js?8c4f:2062)
    at createNavigationDuplicatedError (vue-router.esm.js?8c4f:2035)
    at HTML5History.confirmTransition (vue-router.esm.js?8c4f:2195)
    at HTML5History.transitionTo (vue
-router.esm.js?8c4f:2125) at HTML5History.push (vue-router.esm.js?8c4f:2492) at eval (vue-router.esm.js?8c4f:2913) at new Promise (<anonymous>) at VueRouter.push (vue-router.esm.js?8c4f:2912) at VueRouter.vue_router__WEBPACK_IMPORTED_MODULE_1__.default.push (index.js?a18c:34) at handler (vue
-router.esm.js?8c4f:1100)

// 判斷路徑的路由是否一致
function
isSameRoute (a, b) { if (b === START) { return a === b } else if (!b) { return false } else if (a.path && b.path) {
  // 一致的路由,會走到這個位置
return ( a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') && a.hash
=== b.hash && isObjectEqual(a.query, b.query) ) } else if (a.name && b.name) { return ( a.name === b.name && a.hash === b.hash && isObjectEqual(a.query, b.query) && isObjectEqual(a.params, b.params) ) } else { return false } }

vue-router.esm.js檔案中的定位位置,可直接Debug即可