Skip to content

[vue] 如果vue-router使用history模式,部署时要注意什么? #370

New issue

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

Open
haizhilin2013 opened this issue Jun 20, 2019 · 3 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] 如果vue-router使用history模式,部署时要注意什么?

@haizhilin2013 haizhilin2013 added the vue vue label Jun 20, 2019
@gaozhe3321
Copy link

服务器的404页面需要重定向到index.html

@klren0312
Copy link

nginx
try_files $uri $uri/ /index.html;

@yxllovewq
Copy link

vue应用为SPA,hash模式下,改变hash值,网络请求地址不会变,刷新url或者改变url不会出现404问题。
history模式,如果刷新url或改变url,网络请求的地址不存在,因为vue应用实际只有一个html,找不到会出现404错误。
解决办法,将所有的网络请求全部指向根页面,就不会出现404了,也即上面给出的答案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

4 participants