一.项目配置

1.路由配置
在router配置文件中加入mode: ‘history’, 如果nginx配置文件中要映射到子文件mobile,那么要配置 base: ‘/mobile/’
在这里插入图片描述
2.打包配置
如果nginx配置文件中要映射到子文件mobile,那么要在config目录下的index.js中build打包配置下将 assetsPublicPath: ‘/’ 修改为 assetsPublicPath: ‘/mobile/’
在这里插入图片描述

二.nginx配置

vue history模式nginx配置必须加上 try_files

server {
      listen       80;
       server_name  www.xxxxx.com xxxxx.com; 
       location / {
            root   /usr/local/nginx/html/adminWeb;
            index  index.html index.htm;
		    #proxy_pass http://localhost:8080/;
       }
       
       location /mobile {
	        #root /usr/local/nginx/html;
			try_files $uri $uri/ /mobile/index.html;
	   } 
}
Logo

前往低代码交流专区

更多推荐