-
- 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;
- }
- }
- })
- },
-
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
}
})
}