- 当前 Bug 的表现(可附上截图)
- 预期表现
数组setData更新数据会覆盖前面元素
- 复现路径
setData
- 提供一个最简复现 Demo
setData内容{"listData[0]":{"id":0,"code":"pdtid","text":"产品编号:","type":"text","value":"","isdisplay":true},"listData[0].id":0,"listData[0].value":"w11111-1","listData[1]":{"id":0,"code":"pdtname","text":"产品名称:","type":"text","value":"","isdisplay":true},"listData[1].id":0,"listData[1].value":"产品1-1","listData[2]":{"id":0,"code":"anticode","text":"溯源码:","type":"number","value":"","isdisplay":false},"listData[2].id":0,"listData[3]":{"id":0,"code":"remark","text":"异常备注:","type":"text","value":"","isdisplay":false},"listData[3].id":0,"listData[4]":{"id":0,"code":"pdtid","text":"产品编号:","type":"text","value":"","isdisplay":true},"listData[4].id":1,"listData[4].value":"w11111-2","listData[5]":{"id":0,"code":"pdtname","text":"产品名称:","type":"text","value":"","isdisplay":true},"listData[5].id":1,"listData[5].value":"产品1-2","listData[6]":{"id":0,"code":"anticode","text":"溯源码:","type":"number","value":"","isdisplay":false},"listData[6].id":1,"listData[7]":{"id":0,"code":"remark","text":"异常备注:","type":"text","value":"","isdisplay":false},"listData[7].id":1}
pdtadd.js? [sm]:170 listData的值[{"id":1,"code":"pdtid","text":"产品编号:","type":"text","value":"w11111-2","isdisplay":true},{"id":1,"code":"pdtname","text":"产品名称:","type":"text","value":"产品1-2","isdisplay":true},{"id":1,"code":"anticode","text":"溯源码:","type":"number","value":"","isdisplay":false},{"id":1,"code":"remark","text":"异常备注:","type":"text","value":"","isdisplay":false},{"id":1,"code":"pdtid","text":"产品编号:","type":"text","value":"w11111-2","isdisplay":true},{"id":1,"code":"pdtname","text":"产品名称:","type":"text","value":"产品1-2","isdisplay":true},{"id":1,"code":"anticode","text":"溯源码:","type":"number","value":"","isdisplay":false},{"id":1,"code":"remark","text":"异常备注:","type":"text","value":"","isdisplay":false}]
console.log("setData内容" + JSON.stringify(param));
this.setData(param);
console.log("listData的值" + JSON.stringify(that.data.listData));
微信小程序开发问题解答
微信小程序开发者回答:
请把问题描述清楚。
你想要干嘛?
出现了什么问题?
微信小程序开发者回答:
相当的复杂啊
微信小程序开发者回答:
浅拷贝的数据拿不到
微信小程序开发者回答:
let arr=this.data.arr;
arr[0].id"=0;
arr[1].id=1;
this.setData({arr:arr})
浅拷贝的数据拿不到
微信小程序开发者回答:
问题已搞定,浅拷贝的问题。
本文网址:http://www.91bianli.com/weixinxiaochengxu/1637.html