Avoided redundant navigation to current location: “/home“.

错误出现原因 - 在进行路由跳转时,重复点击跳转到同一个路径下出现以上错误

这是vue在3.0以上的版本中的错误提示,不允许从当前路由跳转到当前路由(所以先检查一下哪里路由跳转重复了吧)

解决方案

在router的(inedx.js)配置文件中添加如下代码

import Vue from 'vue'
import VueRouter from 'vue-router'
 
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
 
Vue.use(VueRouter)

猜你喜欢

转载自blog.csdn.net/CSDN_33901573/article/details/124141507
今日推荐