【问题标题】:React native this.props.screenProps.mapLoc.markers.map is not a function反应原生 this.props.screenProps.mapLoc.markers.map 不是函数
【发布时间】:2018-02-27 10:14:41
【问题描述】:

我有以下问题,无法解决。我正在关注 react-native-maps 示例并尝试设置标记。但是 .map() 不断弹出错误:

this.props.screenProps.mapLoc.markers.map 不是函数

代码是:

        <MapView
          style={{ left:0, right: 0, top:0, bottom: 0, position: 'absolute', backgroundColor: '#fff' }}
          region={this.state.region}
          onRegionChange={this.onRegionChange.bind(this)}
        >
          {this.props.screenProps.mapLoc.markers.map(marker => (
            <MapView.Marker
              coordinate={marker.Coords}
              title={marker.Name}
              description={marker.Description}
            />
          ))}
        </MapView>

数据是参数在那里并且应该:

{"screenProps":{"cats":[],"mapLoc":{"markers":{"Name":"Blank","Description":"Blank","Coords":{"latitude" :56.947902,"longitude":24.097722}}}},"navigation":{"state":{"key":"Map","routeName":"Map"}}}

不知道发生了什么。

【问题讨论】:

    标签: javascript react-native react-native-android react-native-maps


    【解决方案1】:

    对象没有函数map()only arrays do

    this.props.screenProps.mapLoc.markers 是一个对象。

    【讨论】:

      猜你喜欢
      • 2015-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-05
      • 2021-12-08
      • 2022-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多