一:函数使用
wx.request()基本格式:
wx.request({
url: url,
data: {
x:‘ ’,
y:' '},
header: {
'Content-Type': 'application/json'
},
success: function (res) {
console.log(res.data)
var feed_data = res.data;
console.log(feed_data);
that.setData({
question: feed_data,
});
},
fail: function (res) {
console.log("failed")
}
})
二:url如果为本地连接localhost时,请求接口会显示URL不合法,此时点击开发者工具中的详情-项目设置-选择不校验合法域名、web-view(业务域名)、TLS 版本以及 HTTPS 证书