- for循环问题
[代码]onLoad: [代码][代码]function[代码][代码](options) {[代码][代码] [代码][代码]db.collection([代码][代码]'users'[代码][代码]).where({[代码][代码] [代码][代码]pid: app.globalData.openid[代码][代码] [代码][代码]})[代码][代码] [代码][代码].get().then(res => {[代码][代码] [代码][代码]console.log(res.data)[代码][代码] [代码][代码]var[代码] [代码]sons = res.data[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i = 0; i < res.data.length; i++) {[代码][代码] [代码][代码]console.log(i) //这里i=0[代码][代码] [代码][代码]db.collection([代码][代码]'users'[代码][代码]).where({[代码][代码] [代码][代码]pid: res.data[i]._openid[代码][代码] [代码][代码]})[代码][代码] [代码][代码].get().then(res => {[代码][代码] [代码][代码]console.log(i) //这里i=1[代码][代码] [代码][代码]sons[i-1].gsons = res.data[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]sons: sons[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log([代码][代码]this[代码][代码].data)[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]},[代码]为什么第一个i=0,第二个i=1
2019-04-04 - data 对象数组嵌套取不到值问题
<text>{{sons[0].gsons[0]._openid}}</text>取不到值 data如下: sons:Array(1) 0: gsons:Array(1) 0:{_id: "XJ4A2JT75u223hvj", _openid: "o4mgg0XJmnZjCjHOqfHnpjyGxtfk", isSeller: false, phone: "159****3703", pid: "o4mgg0bw14VjeUS_iInjr12hl7sE", …} length:1 nv_length:(...) __proto__:Array(0) isSeller:false pid:"o4mgg0XJmnZjCjHOqfHnpjyGxtfk" userInfo:{avatarUrl: "https://wx.qlogo.cn/mmopen/vi_32/z4wepTcrcmEtyABhk…WocBU0eZqKvWKQrwz1T9kMrFxtxxgjbFFLRPKxxN5Oaew/132", city: "Jinhua", country: "China", gender: 1, language: "zh_CN", …} _id:"XKR4nHffS3SWepQL" _openid:"o4mgg0bw14VjeUS_iInjr12hl7sE"
2019-04-04