小程序里面對(duì)后臺(tái)返回的數(shù)據(jù)添加新的字段
小程序里面對(duì)后臺(tái)返回的數(shù)據(jù)添加新的字段。
1,在寫(xiě)小程序的時(shí)候,發(fā)現(xiàn)xml里面顯示的數(shù)據(jù)在一個(gè)item的list的數(shù)組里面。比如

我的xml里面要顯示item =3的fyhqmz的2個(gè)值的和(10+15)

比如這樣
所以我就想自己去添加一個(gè)字段,
從現(xiàn)在的后臺(tái)返回的數(shù)據(jù)結(jié)構(gòu)

轉(zhuǎn)換成這樣的

that2.setData({ itemList: JSON.parse(res.data).data.list, })
console.log("item[]", that2.data.itemList) for (let i = 0; i < that2.data.itemList.length;i++){ var item1 = that2.data.itemList[i]; console.log("每個(gè)item",item1) var aa=item1.list; console.log("每個(gè)aa", aa) for (let i = 0; i that2.setData({ itemtotalmoney: 0, })

直接添加字段,并賦值。