const eventSeatSelectCallback = (
SeatPrice,
FlightNumber,
SegmentKey
) => {
var postObject = { ...state.post };
postObject.IsSeatSelected = true;
postObject.AirPassengerList.filter(
(x) =>
x.FlightNumber == FlightNumber.toString() &&
x.SegmentKey.toString() == SegmentKey.toString() &&
x.IsSelected == true
)[0].SeatPrice = SeatPrice;
`
dispatch({ type: "UPDATE_SEATFORPASSENGER", payLoad: postObject });
};
上面的行在控制台中给出错误,如未捕获的TypeError:无法设置未定义(设置“SeatPrice”)的属性我正在尝试将AirPassengerList.SeatPrice的值设置为SeatPrice
我想将对象AirPassengerList.SeatPrice的值设置为参数SeatPrice的值
1条答案
按热度按时间hzbexzde1#
您可以通过索引更新元素
希望能有所帮助