Vue Router 重新访问 url 时返回 404 [英] Vue Router return 404 when revisit to the url

查看:35
本文介绍了Vue Router 重新访问 url 时返回 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是启用了 Vue 路由器历史模式.当我通过 v-href 或 href 访问 vue 路由时,它工作正常.但是,当我尝试刷新该页面或直接从浏览器地址栏进入时,它只会返回 404.是否有任何选项可以接受对该 URL 的刷新/重新访问?

I just enable Vue router history mode. And it work fine when I visit to vue routing via v-href or href. But, when I try to refresh that page or go directly from browser address bar, it just return 404. Is there any option to accept refresh/revisit to that url?

以下是我的Vue路由器配置

The following is my Vue router configuration

var router = new VueRouter({
  hashbang: false,
  history: true,
  mode: 'html5',
  linkActiveClass: "active",
  root:  '/user'
});

推荐答案

通过刷新页面,您使用当前 url 向服务器发出请求,服务器返回 404.您必须在 Web 框架或 Web 上处理此问题服务器级别.

By refreshing the page you are making a request to the server with the current url and the server returns 404. You have to handle this on your web framework or web server level.

https://router.vuejs.org/en/essentials/history-模式.html

这篇关于Vue Router 重新访问 url 时返回 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆