setdata给数组设值得执行顺序
Page({
data: {
list: [{
‘A’: 11,
‘B’: 12
},
{
‘A’: 21,
‘B’: 22
},
{
‘A’: 31,
‘B’: 32
},
{
‘A’: 41,
‘B’: 42
}
],
A: 0
},
onLoad: function(options) {
var that = this
console.log(“111”)
console.log(this.data.list)
setTimeout(function() {
console.log(“设值”)
var str=‘list[0].A’
that.setData({
[str]: 2
}, function() {
console.log(“设值完成”)
console.log(that.data.list)
})
}, 1000)
console.log(“222”)
console.log(this.data.list)
}
})
为什么我加了延迟 111和222后的list[0].A还是2 这个时候都还没有执行setData