我正在尝试映射一个对象数组:
{"vehicles":[{"id":"xe","modelYear":"k17","url":"/api/vehicle/xe","media":[{"name":"vehicle","url":"/images/xe_k17.jpg"}]},{"id":"xf","modelYear":"k17","url":"/api/vehicle/xf","media":[{"name":"vehicle","url":"/images/xf_k17.jpg"}]},{"id":"xj","modelYear":"k16","url":"/api/vehicle/xj","media":[{"name":"vehicle","url":"/images/xj_k16.jpg"}]},{"id":"fpace","modelYear":"k17","url":"/api/vehicle/fpace","media":[{"name":"vehicle","url":"/images/fpace_k17.jpg"}]},{"id":"ftype","modelYear":"k17","url":"/api/vehicle/ftype","media":[{"name":"vehicle","url":"/images/ftype_k17.jpg"}]}]}
然而,我收到错误:
无法读取未定义的属性“地图”
这是我的地图:
var vehicleNodes = this.props.data.vehicles.map(function(vehicle){
return (
<tr key={vehicle.id}>
<Td to={`/posts/${vehicle.id}`}>{vehicle.id}</Td>
<Td to={`/posts/${vehicle.id}`}>{vehicle.name}</Td>
<Td to={`/posts/${vehicle.id}`}>{vehicle.username}</Td>
<Td to={`/posts/${vehicle.id}`}>{vehicle.email}</Td>....