1
我有以下問題,不能包裹我的頭。我正在關注react-native-maps示例並嘗試設置標記。然而.MAP()不斷出現的錯誤:反應原生this.props.screenProps.mapLoc.markers.map不是一個函數
this.props.screenProps.mapLoc.markers.map is not a function
的代碼是:
<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>
數據是params爲存在和應該:
{"screenProps":{"cats":[],"mapLoc":{"markers":{"Name":"Blank","Description":"Blank","Coords":{"latitude":56.947902,"longitude":24.097722}}}},"navigation":{"state":{"key":"Map","routeName":"Map"}}}
不知道是怎麼回事。