来自外部源的Vue-Router URL总是重定向到“/&quot”
我直接在Vue Dev服务器上运行VUE 2。
我正在尝试从外部URL进入VUE路线(Vue-Router)。
<a href="http://localhost:8080/reset_password/{{ reset_email_token }}">Passwort zurücksetzen</a>
由于某种原因,我不知道,Vue-Router总是将我的请求重定向并像从“/”一起处理,然后自动将其重定向到“/登录”,
我在这里找到了一个类似的问题( https://forum.vuejs.s.s.s.org/t/access-to- -a-a-vue-route-from-from-from-external-link/107250 ),但没有解决方案。
有人知道这个问题并知道如何评估可能的解决方案吗?提前致谢!
我的路由文件:
Vue.use(VueRouter);
const router = new VueRouter({
routes: [
{
path: "/login",
name: "Login",
component: Login,
},
{
path: "/reset_password/:token", // --> this is the path I want to access from external
name: "resetPassword",
component: resetPassword,
},
{
path: "/forgot_password", // --> this also routes to "/" if coming from extern
name: "forgotPassword",
component: forgotPassword,
},
{
path: "/", // --> this is where url requests from external end up
redirect: "login",
name: "Layout",
component: Layout,
meta: { authRequired: true },
children: [
{
path: "/start",
name: "Start",
component: Start,
meta: { authRequired: true },
},
],
},
{
path: "*",
name: "Error",
component: Error,
},
],
});
I am running Vue 2 directly off the Vue dev server.
I am trying to enter a vue route (vue-router) from an external url.
<a href="http://localhost:8080/reset_password/{{ reset_email_token }}">Passwort zurücksetzen</a>
For some reason I don't know, vue-router always redirects my request and handles it as if it comes from "/", which automatically redirects to "/login"
I found a similiar questions here (https://forum.vuejs.org/t/access-to-a-vue-route-from-external-link/107250) but there is no solution to it.
Has anyone knowledge of this problem and knows how to appraoch a possible fix? Thanks in advance!
My routes.js file:
Vue.use(VueRouter);
const router = new VueRouter({
routes: [
{
path: "/login",
name: "Login",
component: Login,
},
{
path: "/reset_password/:token", // --> this is the path I want to access from external
name: "resetPassword",
component: resetPassword,
},
{
path: "/forgot_password", // --> this also routes to "/" if coming from extern
name: "forgotPassword",
component: forgotPassword,
},
{
path: "/", // --> this is where url requests from external end up
redirect: "login",
name: "Layout",
component: Layout,
meta: { authRequired: true },
children: [
{
path: "/start",
name: "Start",
component: Start,
meta: { authRequired: true },
},
],
},
{
path: "*",
name: "Error",
component: Error,
},
],
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将VUE-ROUTER模式从“哈希”转换为“历史”为我解决了问题。
有关历史模式的参考,请参见此处: https:///v3.router。 vuejs.org/guide/essentials/history-mode.html
Switching vue-router mode from 'hash' to 'history' solved the problem for me.
See here for references on history mode: https://v3.router.vuejs.org/guide/essentials/history-mode.html