数据格式如下,需要改变原数组 解析一下checkList
let data = [
{
"message": "未查询到单据 '2a0c166c-08c0-4e3c-b83c-6b1bdf24c113' 对应计量单位!",
"id": "2a0c166c-08c0-4e3c-b83c-6b1bdf24c113",
"productname": "iphone13",
"productcode": "0003",
"barcode": "",
"category": "ab22b722-f3f2-4b34-a38c-311838fd554f",
"categoryName": "笔记本",
"brand": "3ca06784-de9c-400a-b7b0-826c231bfeaa",
"brandName": "Apple",
"spectemplate": "312e36e4-a74d-464c-b165-c3fc03dab03e",
"spectemplateName": "颜色",
"measureunit": "",
"listprice": 0,
"isrecommend": "1",
"description": "",
"lastModifier": "",
"createdTime": "2021-10-09 11:21:39",
"lastModifiedTime": "2021-10-11 14:15:36",
"rightList": [
{
"id": "5fdb8dd0-5f67-4c8b-a23d-081de97717b1",
"parentId": "2a0c166c-08c0-4e3c-b83c-6b1bdf24c113",
"attributeName1": "大小1",
"attributeValue1": "小",
"attributeName2": "颜色",
"attributeValue2": "白色",
"skuCode": "1001",
"skuName": "iphone13",
"price": 6000,
"isShelf": "上架",
"uniqueCategoryKey": "1323"
},
{
"id": "d08c8f6b-f53f-49f2-b681-06d9e1c42cef",
"parentId": "2a0c166c-08c0-4e3c-b83c-6b1bdf24c113",
"attributeName1": "大小1",
"attributeValue1": "小",
"attributeName2": "颜色",
"attributeValue2": "黑色",
"skuCode": "1002",
"skuName": "iphone13pro",
"price": 7000,
"isShelf": "上架",
"uniqueCategoryKey": "1322"
}
],
"checkList": [
"{\"id\":\"5fdb8dd0-5f67-4c8b-a23d-081de97717b1\",\"parentId\":\"2a0c166c-08c0-4e3c-b83c-6b1bdf24c113\",\"attributeName1\":\"大小1\",\"attributeValue1\":\"小\",\"attributeName2\":\"颜色\",\"attributeValue2\":\"白色\",\"skuCode\":\"1001\",\"skuName\":\"iphone13\",\"price\":6000,\"isShelf\":\"上架\",\"uniqueCategoryKey\":\"1323\"}",
"{\"id\":\"d08c8f6b-f53f-49f2-b681-06d9e1c42cef\",\"parentId\":\"2a0c166c-08c0-4e3c-b83c-6b1bdf24c113\",\"attributeName1\":\"大小1\",\"attributeValue1\":\"小\",\"attributeName2\":\"颜色\",\"attributeValue2\":\"黑色\",\"skuCode\":\"1002\",\"skuName\":\"iphone13pro\",\"price\":7000,\"isShelf\":\"上架\",\"uniqueCategoryKey\":\"1322\"}"
]
}
]
我这么写原数组并没有被改变,求详细解释
//增加属性确定按钮
onSave() {
this.copyLeftData = JSON.parse(JSON.stringify( this.leftData))
this.copyLeftData = this.copyLeftData.filter(items=>items.checkList.length>0)
this.copyLeftData.forEach(item=>{
console.log(item)
item.checkList.forEach(item2=>{
let rightItem = item2;
if (typeof item2 == "string") {
item2 = JSON.parse(item2)
// rightItem = JSON.parse(item2);
// console.log(rightItem,'确定数据11111111111')
}
})
})