为什么 var cp里面没有值

本文详细介绍了在小程序中使用wx.request进行数据请求的方法,并展示了如何处理请求成功后的数据,将其存储在data属性中供页面使用。同时,文章探讨了如何从缓存中读取已保存的数据状态,以及如何对比新旧数据ID来判断是否点击了新的数据项。

wx.request({

url: app.globalData.globalUrl,

data: {

menu: options.title,

},

success: function(res) {

that.setData({

arr_res: res.data.result.data[0],

});

var arr=that.data.arr_res

console.log("有值啦",arr)

that.data.cpids=arr.id

console.log("有值啦", that.data.cpids)

},

fail: function(error) {

that.setData({

})

},

})

var cp = that.data.cpids

console.log("数据", cp)

var postsCollected = wx.getStorageSync("cpData"); //从缓存中读取所有的缓存状态

var posid = this.data.posid

postsCollected.forEach(item => {

posid = item.ids

console.log("id", posid)

})

if (posid != cp) {

this.data.isClick == true

} else {

this.data.isClick == false

}

},

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值