微信小程序修改数组中的键值对,或者增加一个键值对

时间:2024-03-27 21:33:25

items: [
{ findorgettime: "10-21", imgUrl: "http://www.diyunlong.top//maven//upload//tmp_33e660c0174ce4632ec773583982de2b50f5f5b4ed8085ce.jpg", itemclass: "招领", itemclassbig: "钥匙", itemclasssmall: "钥匙1", itemmessage: "一抹夕阳去,乱了阵脚", locationBig: "教学楼", locationSmall: "1栋", numbering: 7, peopleqq: "58846587", peopletel: "17754017059", posttime: "2017-11-26 15:25:51" },
{ findorgettime: "10-21", imgUrl: "http://www.diyunlong.top//maven//upload//tmp_33e660c0174ce4632ec773583982de2b50f5f5b4ed8085ce.jpg", itemclass: "招领", itemclassbig: "钥匙", itemclasssmall: "钥匙1", itemmessage: "一抹夕阳去,乱了阵脚", locationBig: "教学楼", locationSmall: "1栋", numbering: 7, peopleqq: "58846587", peopletel: "17754017059", posttime: "2017-11-26 15:25:51" },
{ findorgettime: "10-21", imgUrl: "http://www.diyunlong.top//maven//upload//tmp_33e660c0174ce4632ec773583982de2b50f5f5b4ed8085ce.jpg", itemclass: "招领", itemclassbig: "钥匙", itemclasssmall: "钥匙1", itemmessage: "一抹夕阳去,乱了阵脚", locationBig: "教学楼", locationSmall: "1栋", numbering: 7, peopleqq: "58846587", peopletel: "17754017059", posttime: "2017-11-26 15:25:51" },
{ findorgettime: "10-21", imgUrl: "http://www.diyunlong.top//maven//upload//tmp_33e660c0174ce4632ec773583982de2b50f5f5b4ed8085ce.jpg", itemclass: "招领", itemclassbig: "钥匙", itemclasssmall: "钥匙1", itemmessage: "一抹夕阳去,乱了阵脚", locationBig: "教学楼", locationSmall: "1栋", numbering: 7, peopleqq: "58846587", peopletel: "17754017059", posttime: "2017-11-26 15:25:51" },
{ findorgettime: "10-21", imgUrl: "http://www.diyunlong.top//maven//upload//tmp_33e660c0174ce4632ec773583982de2b50f5f5b4ed8085ce.jpg", itemclass: "招领", itemclassbig: "钥匙", itemclasssmall: "钥匙1", itemmessage: "一抹夕阳去,乱了阵脚", locationBig: "教学楼", locationSmall: "1栋", numbering: 7, peopleqq: "58846587", peopletel: "17754017059", posttime: "2017-11-26 15:25:51" }, { findorgettime: "10-21", imgUrl: "http://www.diyunlong.top//maven//upload//tmp_33e660c0174ce4632ec773583982de2b50f5f5b4ed8085ce.jpg", itemclass: "寻物", itemclassbig: "钥匙", itemclasssmall: "钥匙1", itemmessage: "一抹夕阳去,乱了阵脚", locationBig: "教学楼", locationSmall: "1栋", numbering: 7, peopleqq: "58846587", peopletel: "17754017059", posttime: "2017-11-26 15:25:51" }
],//存放获取的物品信息数组

我想要在每一个对象的后面增加一个键值对:color:red

那么,如果使用正常的赋值方法肯定是有问题的:


微信小程序修改数组中的键值对,或者增加一个键值对


所以我们使用如下方法来解决这个问题:

微信小程序修改数组中的键值对,或者增加一个键值对

如此以来就解决了!