微信小程序 网络请求
创新互联建站2013年至今,先为越秀等服务建站,越秀等地企业,进行企业商务咨询服务。为越秀企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
1.post请求:
onLoad: function() { that = this; wx.request( { url: "url", header: { "Content-Type": "application/x-www-form-urlencoded" }, method: "POST", data: {}, complete: function( res ) { console.log(res.data) }); if( res == null || res.data == null ) { console.error( '网络请求失败' ); return; } } }) },
2.GET请求
onLoad: function () { console.log('onLoad') var that = this wx.request({ url: 'http://json.bmbstack.com/cinemaList', data: {}, method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT header: { 'Accept': 'application/json' }, // 设置请求的 header success: function(res){ that.data.items= res.data }, fail: function() { // fail }, complete: function() { // complete } }) }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
分享文章:微信小程序网络请求(post请求,get请求)
文章路径:https://www.cdcxhl.com/article11/jhjigd.html
成都网站建设公司_创新互联,为您提供Google、微信小程序、面包屑导航、全网营销推广、ChatGPT、响应式网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联