在wxml里面
<button bind:tap="onReq">网络请求</button>
在wxjs里面
wx.request({
url: 'http://localhost:4000/hello',
data: {name:"yifei"},
method: 'post', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
// header: {}, // 设置请求的 header
success: function(res){
// success
console.log(res,"res")
},
fail: function() {
// fail
console.log("fail")
},
complete: function() {
// complete
}
})
配置