Skip to content

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

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

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

Activity

gaozhe3321

gaozhe3321 commented on Jun 28, 2019

@gaozhe3321

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

klren0312

klren0312 commented on Jul 2, 2019

@klren0312

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

yxllovewq

yxllovewq commented on Mar 10, 2022

@yxllovewq

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gaozhe3321@haizhilin2013@klren0312@yxllovewq

        Issue actions

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