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

怼烎@ 2023-06-16 13:58 117阅读 0赞

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01pc3NfbGlhbmdybQ_size_16_color_FFFFFF_t_70

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

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

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

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

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

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

  1. import VueRouter from "vue-router";
  2. // 重写路由的push方法
  3. const routerPush = VueRouter.prototype.push
  4. VueRouter.prototype.push = function push(location) {
  5. return routerPush.call(this, location).catch(error=> error)
  6. }

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01pc3NfbGlhbmdybQ_size_16_color_FFFFFF_t_70 1

ღ( ´・ᴗ・` )❤完。

发表评论

表情:
评论列表 (有 0 条评论,117人围观)

还没有评论,来说两句吧...

相关阅读