在vue项目中 当路由跳转当前页面时会报错

vue-router.esm.js?8c4f:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/".
    at createRouterError (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2066:15)
    at createNavigationDuplicatedError (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2036:15)
    at HashHistory.confirmTransition (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2334:18)
    at HashHistory.transitionTo (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2261:8)
    at HashHistory.push (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2716:10)
    at eval (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:3035:22)
    at new Promise (<anonymous>)
    at VueRouter.push (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:3034:12)
    at VueComponent.handleLogin (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/views/Login/index.vue?vue&type=script&lang=js&:17:20)
    at click (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"3f39d854-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/views/Login/index.vue?vue&type=template&id=aeba673c&scoped=true&:18:34)

为了解决这个问题在router文件夹index.js里配置了以下代码就可以解决啦:

// 解决跳转到当前路由报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
                    在vue项目中 当路由跳转当前页面时会报错vue-router.esm.js?8c4f:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/".    at createRouterError (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2066:15)   
				
背景:项目通过菜单栏切换界面时候出现如下问题,虽然不影响界面的切换及系统的使用,但是会影响到系统的稳健性。 原因:上面截图显示的问题是系统进行路由切换时出现的问题,主要是vue-router版本问题vue-router 3.0版本以上的回调形式是promise api的形式,返回的是一个promise,如果没有捕获到错误,控制台始终会出现上图的警告。 解决方法: 1.安装低版本的vue-router或者捕获抛出放入错误; 2.删除node_modules文件夹,然后使用“cnpm install”重新安
在安装axios的时候,运行然后报一大堆错,比如 error in ./node_modules/axios/index.js Module build failed: Error: ENOENT: no such file or directory, open 'src/' Uncaught Error: Module build failed: Error: EPERM: operation not permitted, open '\node_modules\webpack\hot
错误解决 node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules
cnpm install(这一步报错cnpm不是内部或外部命令的话, cnpm -v 看下有没有版本号, 然后 npm install cnpm -g --registry=https://registry.npm.taobao.org) npm run serve
二级标题webpack-internal:///./node_modules/vue/dist/vue.esm.js:629 [Vue warn]: Invalid prop: type check failed for prop “dataSource”. Expected Array, got String with value “”. found in 这种报错 应该怎么修改 1、首先f12看一下我们报什么错 这个错 一看就是 data(){ 这里边的错 换完以后还是报错, 改完一个错基本都
Vue-router提供了三种路由模式:hash模式、history模式和abstract模式。\[2\]其中,hash模式是默认模式,URL后面带有#,使用URL的hash值来作为路由,支持所有浏览器。\[3\]history模式通过设置mode: 'history'来改变,使用HTML5的History API来实现路由,可以使页面跳转而不刷新,页面的状态被维持在浏览器中。\[2\]但是,history模式的缺点是如果后端没有处理刷新的情况,前端刷新会发送实际的请求到服务器,导致消耗时间较多且较慢。\[3\]最后,abstract模式是一种抽象模式,具体细节没有提及。 #### 引用[.reference_title] - *1* [vue-router路由模式详解](https://blog.csdn.net/qq_47443027/article/details/115271816)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Vue的三种路由模式](https://blog.csdn.net/yiwai6998/article/details/109512861)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]