manifest.json 添加配置文件
"h5" : {
"devServer" : {
"port" : 8083,
"disableHostCheck" : true,
"proxy" : {
"/api" : {
"target" : "https://api-hmugo-web.itheima.net",
"changeOrigin" : true,
"secure" : false
}
}
}
}
mounted 中添加请求参数
mountted(){
uni.request({
url: "/api/api/public/v1/home/swiperdata", //仅为示例,并非真实接口地址。
method:'get',
data: {
'Content-Type': 'uni.request'//这是传递过去的参数
},
header: {
'custom-header': 'hello' //请求头信息
},
success: (res) => {
console.log(res)
console.log(res.data);//接收到的参数
}
});
}
配置成功后,因HerbuilderX热加载问题,需要重新启动项目,避免控制台打印html代码!