vue-router重复点击路由报错问题vue-router.esm.js?fe87:2051 Uncaught (in promise) NavigationDuplicated {_name: “

报错信息:

vue-router.esm.js?fe87:2051 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated", message: "Navigating to current location ("/recommend/000Si7u14BaKKw") is not allowed", stack: "Error↵    at new NavigationDuplicated (webpack-int…node_modules/vue/dist/vue.runtime.esm.js:1853:26)"}

解决办法:

在包含这句代码 Vue.use(Router) 的文件中加入如下代码:

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

原文地址:
[https://blog.csdn.net/qq_16687863/article/details/103892632] (https://blog.csdn.net/qq_16687863/article/details/103892632)

你可能感兴趣的:(vue,js,router,vue-router,vue,router-link)