Skip to main content

vue: 1 篇

查看所有标签(分类)

Vue3+Vue-router4 解决 history 模式项目访问以及404问题

写在开头#

Vue 路由的 url 有两种模式:hash 模式以及 history 模式。

hash 模式在 url 上面出现一个 # 哈希字符(http://10.1.xx.xx:3006/#/home),不是很美观,不像正常的 url 一样 http://10.1.xx.xx:3006/home

使用 history 模式像正常的 url 一样,还需要后台配置支持 为我们的应用是个单页客户端应用,如果后台没有正确的配置,当用户在浏览器直接访问 http://oursite.com/user/id 就会返回 404,这就不好看了。