var _this = this
_this.setData({
goodsId: e.currentTarget.dataset.goodsId,
coverImg: e.currentTarget.dataset.coverImg,
goodsName: e.currentTarget.dataset.goodsName,
specList: e.currentTarget.dataset.specList
})
let specList = e.currentTarget.dataset.specList
var choosedSpecId = [];
var specName = [];
for (let i = 0; i < specList.length; i++) {
specList[i].spec_items[0].isSelect = true
for (let j = 0; j < specList[i].spec_items.length; j++) {
if (j == 0) {
choosedSpecId.push(specList[i].spec_items[j].id);
specName.push(specList[i].spec_items[j].item)
}
}
};
_this.setData({
choosedSpecId: choosedSpecId,
specName: specName,
})错误
因为没有重新渲染数据,数据出不来
var _this = this
_this.setData({
goodsId: e.currentTarget.dataset.goodsId,
coverImg: e.currentTarget.dataset.coverImg,
goodsName: e.currentTarget.dataset.goodsName,
specList: e.currentTarget.dataset.specList
})
let specList = e.currentTarget.dataset.specList
var choosedSpecId = [];
var specName = [];
for (let i = 0; i < specList.length; i++) {
specList[i].spec_items[0].isSelect = true
for (let j = 0; j < specList[i].spec_items.length; j++) {
if (j == 0) {
choosedSpecId.push(specList[i].spec_items[j].id);
specName.push(specList[i].spec_items[j].item)
}
}
};
_this.setData({
choosedSpecId: choosedSpecId,
specName: specName,
specList:specList
})