使用this.setData()动态渲染成功了,不过加了wx.switchTab之后,控制台还是正确输出的,视图层渲染完之后又跳了回去,使用setTimeout对wx.swtichTab延迟也没用,跳转没问题,就是视图层变得混乱了,毫无规律
routeTab(e) {
var that = this;
var ind = e.currentTarget.dataset.select;
// console.log(this.data.list[ind].pagePath);
for (var i = 0; i < that.data.list.length;i++) {
// item[i].check = false;
if (i != ind) {
var tempFalse = 'list[' + i + '].check';
that.setData({
[tempFalse]: false
});
console.log(tempFalse, i);
}
}
// item[ind].check = true;
var tempTrue = 'list[' + ind + '].check';
that.setData({
[tempTrue]: true
});
console.log(tempTrue,ind);
console.log(that.data.list);
setTimeout(()=>{
wx.switchTab({
url: that.data.list[ind].pagePath,
});
},100);
}