解决 Navigating to current location ("/userslist") is not allowed问题。

今天在写一个后台界面的时候,出现了这个报错,Navigating to current location ("/userslist") is not allowed问题。 

” 不允许导航到当前位置(“/userslist”)“

在网上查了下,发现问题,大致如下:

原因:当前访问的路由是相同的。

解决办法:需要重写路由的push方法

在【router/index.js路由页面】

import VueRouter from "vue-router";
// 重写路由的push方法

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

ღ( ´・ᴗ・` )❤完。

发布了270 篇原创文章 · 获赞 50 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/Miss_liangrm/article/details/103262817