文档地址:https://developers.weixin.qq.com/miniprogram/dev/api/ui/custom-component/wx.nextTick.html
我们在开发时,可以在微信开发者工具的详情这里将 校验合法域名关掉,就可以访问局域网中的接口了,不过不能访问本机ip,
另外上线后只能使用https协议,不能用http协议,可添加20个合法域名,不能添加ip地址
我们一般会在App的onLaunch声明周期中发送网络请求或者在Page的onLoad的尚明周期中发送网络请求
// 网路请求 wx.request({ url: ‘http://123.207.32.32:8000/recommend‘, success:res=>{ console.log(res); } })
告诉大家演练各种请求的地址:http://httpbin.org/post|get|...
下面演练一下post请求
wx.request({ url: ‘http://httpbin.org/post‘, method:"post", data:{ name:"coderwhy", age:18 }, success:res=>{ console.log(res); } })
.
原文:https://www.cnblogs.com/fqh123/p/12348138.html