vue 경로 history 모드 새로 고침 페이지 에 404 문제 가 발생 했 습 니 다.

1056 단어
vue hash 모델 에서 URL 에 존재 하 는 '#' 모델 로 이 문 제 를 해결 할 수 있다.그러나 'history' 모드 는 페이지 를 새로 고치 면 404 페이지 가 나온다.해결 방법 은 history 으로 배치 하 는 것 이다.nginx 설정 파일 에서 수정
방법 1:
location /{
    root   /data/nginx/html;
    index  index.html index.htm;
    if (!-e $request_filename) {
        rewrite ^/(.*) /index.html last;
        break;
    }
}

방법 2: vue. js 공식 튜 토리 얼 에서 언급 한https://router.vuejs.org/zh/g...
  server {
        listen       8081;#     80,              
        server_name  myapp.com;
        root        D:/vue/my_app/dist;#vue       dist
        location / {
            try_files $uri $uri/ @router;#       @router     vue    nginx     404
            index  index.html index.htm;
        }
        #     @router,                      ,           
        #    rewrite index.html ,             
        location @router {
            rewrite ^.*$ /index.html last;
        }
        #.......      
  }

좋은 웹페이지 즐겨찾기