【发布时间】:2021-10-04 18:28:47
【问题描述】:
这是我想要做的:
interface VehicleSeatData {
index: number;
positions: Vector3Mp;
}
interface VehicleSeat {
[key: string]: VehicleSeatData;
}
getSeatData(vehicle: VehicleMp): VehicleSeat | null {
if(!vehicle) {
return null;
}
let seats: VehicleSeat = {};
seats['seat_r'].index = vehicle.getBoneIndexByName('seat_r');
seats['seat_pside_f'].index = vehicle.getBoneIndexByName('seat_pside_f');
seats['seat_r'].positions = vehicle.getWorldPositionOfBone(seats['seat_r'].index);
seats['seat_pside_f'].positions = vehicle.getWorldPositionOfBone(seats['seat_pside_f'].index);
return seats;
}
我得到的错误是:
Uncaught TypeError: Cannot set property 'index' of undefined
我不确定我哪里出错了,我读过的所有内容(到目前为止)都告诉我我的方向是正确的。这不可能吗?
【问题讨论】:
标签: typescript object typeerror