欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

vue-router模式为history的项目打包发布后不能通过地址栏里的地址进行路由跳转

程序员文章站 2022-06-06 23:34:45
...

项目打包发布后不能通过地址栏里的地址进行路由跳转,地址栏里回车访问就直接404

本项目使用nginx发布,所以这里只有nginx的配置方式。
修改nginx的配置文件

server {
        listen       8080;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            try_files $uri $uri/ /index.html;#必须要有的
            root   /home/dist/;#打包后的项目路径,index.html所在文件夹
            index  index.html index.htm;
        }
}