先说结论:查看uniapp的h5配置,确定配置正确再发行,nginx的配置网上都是
如果配置了nginx,发现使用二级域名访问报404或页面拒绝访问,问题一般是在uniapp的配置中
nginx配置
nginx中的配置就是加一个location
location /xxx {
root xxx/xxx/xxx;
try_files $uri $uri/ @router;
index index.html index.htm;
}
uniapp配置
主要配置 base 属性
"h5" : {
"devServer" : {
"disableHostCheck" : true, // 禁止访问本地 host 文件
"port" : 80
},
"router" : {
"mode" : "hash",
"base" : "./" // 配置为 ./
}
}