map对象的数组,无法读取未定义错误的属性'map'

时间:2017-06-10 09:56:42

标签: reactjs

我正在尝试映射一个对象数组:

{"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>....  

0 个答案:

没有答案