我的状态为myrecords [],其中包含以下格式的JSON对象:
{
"records": {
"Master Automotives": [
{
"SparePartID": "43",
"Name": "Oil and Lubricants",
"Price": "4500",
"VendorID": "48",
"CompanyName": "Master Automotives",
"Qty": 1,
"TotalPrice": "4500"
},
{
"SparePartID": "45",
"Name": "Lights",
"Price": "2300",
"VendorID": "48",
"CompanyName": "Master Automotives",
"Qty": 1,
"TotalPrice": "2300"
}
],
"Repair Solutions": [
{
"SparePartID": "47",
"Name": "Steering Wheel",
"Price": "1500",
"VendorID": "60",
"CompanyName": "Repair Solutions",
"Qty": 1,
"TotalPrice": "1500"
}
],
"FiveStar Automotives": [
{
"SparePartID": "51",
"Name": "Brakes",
"Price": "234",
"VendorID": "70",
"CompanyName": "FiveStar Automotives",
"Qty": 1,
"TotalPrice": "234"
},
{
"SparePartID": "53",
"Name": "Clutch",
"Price": "999",
"VendorID": "70",
"CompanyName": "FiveStar Automotives",
"Qty": 1,
"TotalPrice": "999"
},
现在,Im在react js中显示此记录,其方式是所有项目均按行显示并按其CompanyNames分组,并且针对每个Item都有一个“数量”输入字段。默认情况下,数量为1,因此TotalPrice与UnitPrice相同。
现在,我希望对Qty的任何特定输入字段进行onChange,JSON对象中相应的 TotalPrice项目也应在myrecords []状态下进行更新。同样,数量也应在myrecords []状态下进行更新。
慕桂英3389331
蝴蝶不菲
相关分类