美文网首页
Vue 向嵌套数组里的每个元素添加字段

Vue 向嵌套数组里的每个元素添加字段

作者: 前端陈陈陈 | 来源:发表于2020-08-25 14:58 被阅读0次
    WechatIMG2.png
    //要向嵌套数组里的每个元素添加字段
    "list": [
    {
    "id": "478",
    "order_no": "202008251039465919",
    "ostatus": "2",
    "admin_id": "18",
    "accept_name": "广东省 惠州市 惠城区 下角丰山一巷3",
    "telphone": "待发货",
    "province": "",
    "city": "",
    "area": "",
    "address": "",
    "create_time": "2020-08-25 10:39",
    "order_amount_hs": "679.80",
    "order_amount_bhs": "561.80",
    "children": [
    {
    "id": "421",
    "order_id": "478",
    "goods_id": "897",
    "product_id": "544",
    "img": "upload/20200723/a2671caa-ccdf-11ea-8814-0242c0a86002.png",
    "goods_name": "【乖乖猴】电动平衡车 X2",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "2020-08-25 10:42",
    "expresssn": "123",
    "freight_id": "57",
    "goods_no": "X11713001-1",
    "seller_id": "0",
    "pths_supply_price": 679.8,
    "ptbhs_supply_price": 561.8,
    "pt_fee": "0.00",
    "market_price": "0.00",
    "spec_array": "[{\"value\": \"u84ddu8272\", \"tip\": \"u84ddu8272\", \"key\": 1595507146.2664857, \"id\": 1}]",
    "status": "4",
    "errinfo": "",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "679.80",
    "ptbhsbhy_supply_price": "561.80",
    "logistics_name": "全际通"
    }
    ]
    },
    {
    "id": "477",
    "order_no": "202008251039465421",
    "ostatus": "2",
    "admin_id": "18",
    "accept_name": "广东省 深圳市 宝安区 新安湖花园17",
    "telphone": "待发货",
    "province": "",
    "city": "",
    "area": "",
    "address": "",
    "create_time": "2020-08-25 10:39",
    "order_amount_hs": "6.70",
    "order_amount_bhs": "6.40",
    "children": [
    {
    "id": "420",
    "order_id": "477",
    "goods_id": "601",
    "product_id": "0",
    "img": "upload/20200812/20200812040226638.jpg",
    "goods_name": "【茶花】肥皂盒 塑料沥水香皂盒时尚香皂盒卫生皂盒(颜色随机发送)",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X08307009",
    "seller_id": "59",
    "pths_supply_price": 6.7,
    "ptbhs_supply_price": 6.4,
    "pt_fee": "3.00",
    "market_price": "19.90",
    "spec_array": "",
    "status": "0",
    "errinfo": "",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "3.70",
    "ptbhsbhy_supply_price": "3.40",
    "logistics_name": ""
    }
    ]
    },
    {
    "id": "476",
    "order_no": "202008251039467128",
    "ostatus": "2",
    "admin_id": "18",
    "accept_name": "广东省 深圳市 宝安区 新安湖花园17",
    "telphone": "待发货",
    "province": "",
    "city": "",
    "area": "",
    "address": "",
    "create_time": "2020-08-25 10:39",
    "order_amount_hs": "0.00",
    "order_amount_bhs": "0.00",
    "children": [
    {
    "id": "419",
    "order_id": "476",
    "goods_id": "1196",
    "product_id": "0",
    "img": "upload/20200723/18ab6a10-cce0-11ea-8814-0242c0a86002.jpg",
    "goods_name": "【洁丽雅】 莫代尔美容童巾*1条",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X13707011",
    "seller_id": "108",
    "pths_supply_price": 10,
    "ptbhs_supply_price": 8.3,
    "pt_fee": "0.00",
    "market_price": "14.80",
    "spec_array": "",
    "status": "1",
    "errinfo": "库存不足",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "10.00",
    "ptbhsbhy_supply_price": "8.30",
    "logistics_name": ""
    }
    ]
    },
    {
    "id": "475",
    "order_no": "202008251039467375",
    "ostatus": "2",
    "admin_id": "18",
    "accept_name": "广东省 深圳市 宝安区 鹤洲新村七巷四",
    "telphone": "待发货",
    "province": "",
    "city": "",
    "area": "",
    "address": "",
    "create_time": "2020-08-25 10:39",
    "order_amount_hs": "0.00",
    "order_amount_bhs": "0.00",
    "children": [
    {
    "id": "418",
    "order_id": "475",
    "goods_id": "1274",
    "product_id": "699",
    "img": "upload/20200723/377c4220-cce0-11ea-8814-0242c0a86002.jpg",
    "goods_name": "【韩国进口】娇吻清火护龈牙膏 抑制口臭 止痛",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X02107007-1",
    "seller_id": "0",
    "pths_supply_price": 13.3,
    "ptbhs_supply_price": 12.1,
    "pt_fee": "0.00",
    "market_price": "38.80",
    "spec_array": "[{\"id\":\"7\",\"type\":null,\"value\":\"\",\"name\":\"\",\"tip\":\"\",\"key\":\"15961856202455\"}]",
    "status": "1",
    "errinfo": "库存不足",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "13.30",
    "ptbhsbhy_supply_price": "12.10",
    "logistics_name": ""
    }
    ]
    },
    {
    "id": "474",
    "order_no": "202008251039462546",
    "ostatus": "2",
    "admin_id": "18",
    "accept_name": "广东省 深圳市 宝安区 鹤洲新村七巷四",
    "telphone": "待发货",
    "province": "",
    "city": "",
    "area": "",
    "address": "",
    "create_time": "2020-08-25 10:39",
    "order_amount_hs": "8.70",
    "order_amount_bhs": "8.20",
    "children": [
    {
    "id": "417",
    "order_id": "474",
    "goods_id": "757",
    "product_id": "0",
    "img": "upload/20200723/735b8b94-ccdf-11ea-8814-0242c0a86002.jpg",
    "goods_name": "【茶花】点断式大号食品果蔬保鲜袋食品袋子一次性用品(100 只)",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X08307055",
    "seller_id": "59",
    "pths_supply_price": 8.7,
    "ptbhs_supply_price": 8.2,
    "pt_fee": "3.00",
    "market_price": "14.80",
    "spec_array": "",
    "status": "0",
    "errinfo": "",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "5.70",
    "ptbhsbhy_supply_price": "5.20",
    "logistics_name": ""
    }
    ]
    },
    {
    "id": "473",
    "order_no": "202008251039465937",
    "ostatus": "2",
    "admin_id": "18",
    "accept_name": "广东省 深圳市 宝安区 鹤洲新村七巷四",
    "telphone": "待发货",
    "province": "",
    "city": "",
    "area": "",
    "address": "",
    "create_time": "2020-08-25 10:39",
    "order_amount_hs": "22.50",
    "order_amount_bhs": "19.50",
    "children": [
    {
    "id": "416",
    "order_id": "473",
    "goods_id": "2778",
    "product_id": "0",
    "img": "upload/20200814/20200814030637589.jpg",
    "goods_name": "【绿稻人】葛根脆片淮山药片脆片膨化片 (番茄/海苔/芥末三种口味各2袋)38g/袋*6袋",
    "goods_nums": "2",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X17702029",
    "seller_id": "151",
    "pths_supply_price": 22.5,
    "ptbhs_supply_price": 19.5,
    "pt_fee": "0.00",
    "market_price": "48.00",
    "spec_array": "",
    "status": "0",
    "errinfo": "",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "22.50",
    "ptbhsbhy_supply_price": "19.50",
    "logistics_name": ""
    }
    ]
    },
    {
    "id": "472",
    "order_no": "202008241459259617",
    "ostatus": "1",
    "admin_id": "3",
    "accept_name": "曾涛",
    "telphone": "13728686815",
    "province": "广东省",
    "city": "惠州市",
    "area": "惠城区",
    "address": "",
    "create_time": "2020-08-24 14:59",
    "order_amount_hs": "679.80",
    "order_amount_bhs": "561.80",
    "children": [
    {
    "id": "415",
    "order_id": "472",
    "goods_id": "897",
    "product_id": "544",
    "img": "upload/20200723/a2671caa-ccdf-11ea-8814-0242c0a86002.png",
    "goods_name": "【乖乖猴】电动平衡车 X2",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X11713001-1",
    "seller_id": "0",
    "pths_supply_price": 679.8,
    "ptbhs_supply_price": 561.8,
    "pt_fee": "0.00",
    "market_price": "0.00",
    "spec_array": "[{\"value\": \"u84ddu8272\", \"tip\": \"u84ddu8272\", \"key\": 1595507146.2664857, \"id\": 1}]",
    "status": "0",
    "errinfo": "",
    "refund_time": "1598327555",
    "refund_remarks": "13123",
    "pthsbhy_supply_price": "679.80",
    "ptbhsbhy_supply_price": "561.80",
    "logistics_name": ""
    }
    ]
    },
    {
    "id": "471",
    "order_no": "202008241459257568",
    "ostatus": "1",
    "admin_id": "3",
    "accept_name": "林惠娟",
    "telphone": "13926523200",
    "province": "广东省",
    "city": "深圳市",
    "area": "宝安区",
    "address": "",
    "create_time": "2020-08-24 14:59",
    "order_amount_hs": "6.70",
    "order_amount_bhs": "6.40",
    "children": [
    {
    "id": "413",
    "order_id": "471",
    "goods_id": "1196",
    "product_id": "0",
    "img": "upload/20200723/18ab6a10-cce0-11ea-8814-0242c0a86002.jpg",
    "goods_name": "【洁丽雅】 莫代尔美容童巾*1条",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X13707011",
    "seller_id": "108",
    "pths_supply_price": 10,
    "ptbhs_supply_price": 8.3,
    "pt_fee": "0.00",
    "market_price": "14.80",
    "spec_array": "",
    "status": "1",
    "errinfo": "库存不足",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "10.00",
    "ptbhsbhy_supply_price": "8.30",
    "logistics_name": ""
    },
    {
    "id": "414",
    "order_id": "471",
    "goods_id": "601",
    "product_id": "0",
    "img": "upload/20200812/20200812040226638.jpg",
    "goods_name": "【茶花】肥皂盒 塑料沥水香皂盒时尚香皂盒卫生皂盒(颜色随机发送)",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X08307009",
    "seller_id": "59",
    "pths_supply_price": 6.7,
    "ptbhs_supply_price": 6.4,
    "pt_fee": "3.00",
    "market_price": "19.90",
    "spec_array": "",
    "status": "0",
    "errinfo": "",
    "refund_time": "1598327788",
    "refund_remarks": "0",
    "pthsbhy_supply_price": "3.70",
    "ptbhsbhy_supply_price": "3.40",
    "logistics_name": ""
    }
    ]
    },
    {
    "id": "470",
    "order_no": "202008241459252427",
    "ostatus": "1",
    "admin_id": "3",
    "accept_name": "方少丽",
    "telphone": "15918895845",
    "province": "广东省",
    "city": "深圳市",
    "area": "宝安区",
    "address": "",
    "create_time": "2020-08-24 14:59",
    "order_amount_hs": "31.20",
    "order_amount_bhs": "27.70",
    "children": [
    {
    "id": "410",
    "order_id": "470",
    "goods_id": "2778",
    "product_id": "0",
    "img": "upload/20200814/20200814030637589.jpg",
    "goods_name": "【绿稻人】葛根脆片淮山药片脆片膨化片 (番茄/海苔/芥末三种口味各2袋)38g/袋*6袋",
    "goods_nums": "2",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X17702029",
    "seller_id": "151",
    "pths_supply_price": 22.5,
    "ptbhs_supply_price": 19.5,
    "pt_fee": "0.00",
    "market_price": "48.00",
    "spec_array": "",
    "status": "0",
    "errinfo": "",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "22.50",
    "ptbhsbhy_supply_price": "19.50",
    "logistics_name": ""
    },
    {
    "id": "411",
    "order_id": "470",
    "goods_id": "757",
    "product_id": "0",
    "img": "upload/20200723/735b8b94-ccdf-11ea-8814-0242c0a86002.jpg",
    "goods_name": "【茶花】点断式大号食品果蔬保鲜袋食品袋子一次性用品(100 只)",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X08307055",
    "seller_id": "59",
    "pths_supply_price": 8.7,
    "ptbhs_supply_price": 8.2,
    "pt_fee": "3.00",
    "market_price": "14.80",
    "spec_array": "",
    "status": "0",
    "errinfo": "",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "5.70",
    "ptbhsbhy_supply_price": "5.20",
    "logistics_name": ""
    },
    {
    "id": "412",
    "order_id": "470",
    "goods_id": "1274",
    "product_id": "699",
    "img": "upload/20200723/377c4220-cce0-11ea-8814-0242c0a86002.jpg",
    "goods_name": "【韩国进口】娇吻清火护龈牙膏 抑制口臭 止痛",
    "goods_nums": "1",
    "goods_weight": "0.00",
    "shiptime": "",
    "expresssn": null,
    "freight_id": "0",
    "goods_no": "X02107007-1",
    "seller_id": "0",
    "pths_supply_price": 13.3,
    "ptbhs_supply_price": 12.1,
    "pt_fee": "0.00",
    "market_price": "38.80",
    "spec_array": "[{\"id\":\"7\",\"type\":null,\"value\":\"\",\"name\":\"\",\"tip\":\"\",\"key\":\"15961856202455\"}]",
    "status": "1",
    "errinfo": "库存不足",
    "refund_time": null,
    "refund_remarks": null,
    "pthsbhy_supply_price": "13.30",
    "ptbhsbhy_supply_price": "12.10",
    "logistics_name": ""
    }
    ]
    }
    ],
    "total": "9"
    }
    }
    
    // 方法:
     this.tableData = res.data.list;
                res.data.list.forEach((m, index) => {
                  for (let i = 0; i < this.tableData.length; i++) {
                    if (this.tableData[i]["children"]) {
                      this.tableData[i]["children"].forEach((item, indexs) => {
                        if(index == i ){
                        item.mstatus = m.ostatus;
                        }
                      });
                    }
                  }
                });
    ···

    相关文章

      网友评论

          本文标题:Vue 向嵌套数组里的每个元素添加字段

          本文链接:https://www.haomeiwen.com/subject/waczjktx.html