小程序的网路请求赋值

var postData;
Page({
data: {
name:"1",
postlist: []
},
onLoad: function (options) {
 
var _this=this;
wx.request({
url: ‘http://localhost:8743/home/weixin‘,
data: {
x: ‘‘,
y: ‘‘
},
header: {
‘content-type‘: ‘application/json‘
},
success(res) {
postData = res.data;
console.log("postData");
console.log(postData);
_this.setData({
postlist: postData,
name: "2"
})
console.log("data");
console.log(_this.data);
}
})
 
 
},
onPostTap: function (event) {
var postId = event.currentTarget.dataset.postid;
 
wx:wx.navigateTo({
url: "post-detail/post-detail?id=" + postId
})
},

onSwiperTap(event) {
var postId = event.target.dataset.postid
wx.navigateTo({
url: ‘post-detail/post-detail?id=‘ + postId
})
},
})

小程序的网路请求赋值

上一篇:微信商户平台小结


下一篇:微信H5网页公众号授权登录