如何在React Native中获取对象内部的数组

时间:2019-11-06 07:08:53

标签: react-native

Object {
  "errorMessage": "",
  "item": Array [
    Object {
      "created_at": "1572602716",
      "description": "Dbjd",
      "id": "1",
      "title": "Hsh",
      "updated_at": "1572602716",
      "user_id": "27",
    },
    Object {
      "created_at": "1572603684",
      "description": "Hh",
      "id": "2",
      "title": "Gg",
      "updated_at": "1572603684",
      "user_id": "27",
    },
    Object {
      "created_at": "1572603975",
      "description": "Tr",
      "id": "3",
      "title": "Gg",
      "updated_at": "1572603975",
      "user_id": "27",
    },
    Object {
      "created_at": "1572854783",
      "description": "Ggg",
      "id": "7",
      "title": "Gtt",
      "updated_at": "1572854783",
      "user_id": "27",
    },
  ],

1 个答案:

答案 0 :(得分:0)

您可以在此处输入objectName.item,

let data = {
  "errorMessage": "",
  "item": Array [
    Object {
      "created_at": "1572602716",
      "description": "Dbjd",
      "id": "1",
      "title": "Hsh",
      "updated_at": "1572602716",
      "user_id": "27",
    },
    Object {
      "created_at": "1572603684",
      "description": "Hh",
      "id": "2",
      "title": "Gg",
      "updated_at": "1572603684",
      "user_id": "27",
    },
    Object {
      "created_at": "1572603975",
      "description": "Tr",
      "id": "3",
      "title": "Gg",
      "updated_at": "1572603975",
      "user_id": "27",
    },
    Object {
      "created_at": "1572854783",
      "description": "Ggg",
      "id": "7",
      "title": "Gtt",
      "updated_at": "1572854783",
      "user_id": "27",
    },
  ],

您可以通过简单地访问

data.item