vue-cli项目路由history模式相关配置
一.项目配置1.路由配置在router配置文件中加入mode: ‘history’, 如果nginx配置文件中要映射到子文件mobile,那么要配置 base: ‘/mobile/’2.打包配置如果nginx配置文件中要映射到子文件mobile,那么要在config目录下的index.js中build打包配置下将 assetsPublicPath: ‘/’修改为 assetsPubl...
·
一.项目配置
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;
}
}
更多推荐
已为社区贡献2条内容
所有评论(0)