【发布时间】:2021-07-16 18:38:09
【问题描述】:
一个 Vue2 应用程序,例如(http://www.example.com)。两条路线('/'、'/dashboard')和'/'将被重定向到'/dashboard'。
-
现在另一个 sso 系统(例如
http://www.sso.com)发送重定向到http://www.example.com?token=xxxxxx, -
然后浏览器执行重定向,Vue路由器将路由识别为'/'并且
-
然后根据路由器设置重定向到'/dashboard'。
但是现在,浏览器地址栏中的 url 就像http://www.example.com?token=xxxxxx#/dashboard,虽然应用程序可以工作,但我想从地址栏中删除查询字符串 '?token=xxxxxx' 但失败了。
我尝试了两种方法:
- 设置 window.location.search=null,但 '?'标志仍在网址中。
- 当 'to' 为 '/' 时使用导航守卫 next('/dashboard'),同样失败。
请有人帮忙,谢谢。
【问题讨论】:
标签: vue.js redirect vuejs2 vue-router