We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vue router 默认模式, 格式类似于 http://localhost:8081/#/register, url 中带有 #, 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。
vue router
http://localhost:8081/#/register
url
#
URL
hash
history 模式就和普通的 url 一样, 通过设置 mode 的值可以改变路由模式
history
mode
const router = new VueRouter({ mode: 'history', routes: [...] })
问题: 路由为 history 模式下, 当直接输入 url 访问或者刷新页面时, 会出现 404, 所以需要后台配置, 一旦 url 匹配不到任何值, 则返回到 index.html , 也就是APP.vue。
404
index.html
APP.vue
location / { try_files $uri $uri/ /index.html; }
以上为 nginx 配置例子
nginx
https://router.vuejs.org/zh-cn/essentials/history-mode.html
The text was updated successfully, but these errors were encountered:
No branches or pull requests
hash 模式
history 模式
问题: 路由为
history
模式下, 当直接输入url
访问或者刷新页面时, 会出现404
, 所以需要后台配置, 一旦url
匹配不到任何值, 则返回到index.html
, 也就是APP.vue
。参考
https://router.vuejs.org/zh-cn/essentials/history-mode.html
The text was updated successfully, but these errors were encountered: