欢迎使用Markdown编辑器
uniapp项目 根目录下找到manifest.json 进入 源码视图
代码
"h5" : {
"devServer" : {
// "publicPath":"./" //注意隐藏这行
"https" : false,
"port" : 8080,
"disableHostCheck" : true,
"proxy" : {
"/api" : {
"target" : "xx.xxxxx.com",
// 你的域名地址,
"ws" : true,
"changOrigin" : true,
"pathRewrite" : {
"^/api" : ""
}
}
}
},
"router" : {
"base" : "/website/",
//填写你的线上地址(如http://m.shop.com/mall/webiste/,线上根目录是http://m.shop.com,取得是根目录后的mall/website, 注意本地开发时需要隐藏这行
"mode" : "history"
}
}
HBuilder发行打包
最后一步在服务器的根目录下创建.htaccess文件
务必是**.htaccess**文件名
文件内的代码如下
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /h5/website/index.html [L]
//如果放的目录不在h5下面 就把/h5去掉即可