|
作者:王梵,
今天,說一下項目開發(fā)中遇到的一些問題,和一些效果。如果大家遇到了一些效果不好實現(xiàn)的,也可以給我留言,移動猿不怕嘗試。 網(wǎng)絡(luò)請求該怎么寫這個似乎不是個問題,但其實是的,先來看一個請求的代碼。
wx.request({
url: 'https://test.wisely.com/index.html?latitude=36.8962&longitude=132.5730',
data: {},
method: 'GET',
success: function(res){
// success
},
fail: function(res) {
// fail
},
complete: function(res) {
// complete
}
})
直接將地址和參數(shù)都拼接起來,賦給url,行不行?可以。但這么寫不規(guī)范,正確地寫法應(yīng)該是下面這樣
wx.request({
url: 'https://test.wisely.com/index.html',
data: {
latitude:36.8962,
longitude:132.5730
},
method: 'GET',
success: function(res){
// success
},
fail: function(res) {
// fail
},
complete: function(res) {
// complete
}
})
|