对象型数组添加字段?
Page({
data: {
arr:[{id:1,name:"张三",num:10},{id:2,name:"李四",num:5},{id:3,name:"王二",num:8},{id:4,name:"麻子",num:6}]
},
onLoad: function () {
arr.map(item=>{
item.price = 11
})
},
})
console.log(arr) //[{id:1,name:"张三",num:10,price:5},{id:2,name:"李四",num:5,price:8},{id:3,name:"王二",num:8,price:10},{id:4,name:"麻子",num:6,price:10}]
{{item.num}}--{{item.price}}
//只显示name,并没有price