smileyby / notes

GitHub Issues Blog, powered by GitHub Issues and GitHub Actions
2 stars 0 forks source link

vue-router 4.x 告警:[Vue Router warn]: No match found for location with path #271

Open smileyby opened 1 year ago

smileyby commented 1 year ago

场景:存在通过 addRoute添加的 异步鉴权路由,当在鉴权路由页面刷新时,会出现以上告警 原因:由于路由匹配先与 addRoute 导致 解决:在路由表中添加 404 路由 代码如下图1

另外一个问题:在刷新时处在动态添加的路由时,路由还未添加的问题 解决办法:在beforeEach 钩子函数中跳转下一步时添加 replace: true即可

代码如下图2

smileyby commented 1 year ago

image image