小编Sug*_*han的帖子

如何在React Native中将json数据映射到数组

我在本机反应中有这样的数组

 const data = [
    { key: 1, label: 'Service1'},
    { key: 2, label: 'Service2' },
    { key: 3, label: 'Service3' },
    { key: 4, label: 'Service4' },
    { key: 5, label: 'Service4' },
 ];
Run Code Online (Sandbox Code Playgroud)

和 json 数据:

 "services": [
    {
      "id": 1,
      "name": "Hotels",
    },
    {
      "id": 2,
      "name": "Embassies",
    },
 ]
Run Code Online (Sandbox Code Playgroud)

如何将mapid 添加到 key 并将名称添加到标签???

arrays rest json react-native

4
推荐指数
1
解决办法
4万
查看次数

标签 统计

arrays ×1

json ×1

react-native ×1

rest ×1