data: {
storeid_arr: [],
storename_arr: [],
store_arr: [],
store_index: 0,
reportdata: {},
hasdata : false,
initstoreid : 9,
},
onLoad: function () {
var that = this
var store_arr_temp = []
var storeid_arr_temp = []
var storename_arr_temp = []
var formData = { uid: 1, channelid: 1}
var reportdata_temp = {}
var hasdata_temp = false
var initstoreid_temp = 0
wx.request({
url: ‘http://cxbb/api/index/getstore’,
data: formData,
method: ‘post’,
header: {
‘Content-Type’: ‘application/json’,
},
success: function (res) {
store_arr_temp = res.data
store_arr_temp.forEach(function (e) {
if (initstoreid_temp == 0) {
initstoreid_temp = e.storeid
}
storeid_arr_temp.push(e.storeid)
storename_arr_temp.push(e.storename)
})
that.setData({
store_arr: store_arr_temp,
storeid_arr: storeid_arr_temp,
storename_arr: storename_arr_temp,
initstoreid: initstoreid_temp,
})
},
fail: function () {
}
})
var formDataReport = {
storeid: this.data.initstoreid,
uid: 1
}
console.log(this.data.initstoreid);
}
这里的this.data.initstoreid一直是9,按理说应该变成initstoreid_temp的值,我就是从服务器取得一些数据然后将其中的一个数值赋给data里的 store_arr, storeid_arr, storename_arr和initstoreid,可是initstoreid的值一直是9,就是那个初始值,其他三个好着呢,求解啊,搞了一天