gpt4 book ai didi

javascript - React Native this.props.screenProps.mapLoc.markers.map 不是一个函数

转载 作者:行者123 更新时间:2023-11-28 04:10:50 25 4
gpt4 key购买 nike

我有以下问题,无法解决。我正在遵循react-native-maps示例并尝试设置标记。然而 .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>

数据是参数,并且应该如此:

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

不知道发生了什么。

最佳答案

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

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

关于javascript - React Native this.props.screenProps.mapLoc.markers.map 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46286681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com