**
初始数据:
**
list: [{
index: 0,
price: 180,
num: 1,
title: “宝儿姐1”,
},
{
index: 1,
price: 170,
num: 1,
title: “宝儿姐2”
},
{
index: 2,
price: 160,
num: 1,
title: “宝儿姐3”
}
]
js function:
for (let index = 0; index < lists.length; index++) {
lists[index].selected = true
}
this.setData({
list: lists
})
结果:
list: [{
index: 0,
price: 180,
num: 1,
title: “宝儿姐1”,
selected: true
},
{
index: 1,
price: 170,
num: 1,
title: “宝儿姐2”,
selected: true
},
{
index: 2,
price: 160,
num: 1,
title: “宝儿姐3”,
selected: true
}
]