我正在尝试从地理编码返回的内容中获取城市名称,但似乎无法以我尝试过的任何方式工作。谁能帮我取悦?
这是我获取位置数据的地方,它返回一个带有区域、街道、城市等数组的对象,如下所示
这一行:
<Text>Location: {this.state.locationResult}</Text>
返回此
[{"region":"England","street":"Holborn street","city":"London"}]
我已经尝试过使用locationResult[0].city,但仍然不起作用。
Тry this:
let obj = this.state.locationResult;
<Text>Location: {obj[0].city}</Text>