简体   繁体   中英

How can I loop through my json data in js to make cards in my html page

var data = 
[  
   {  
      "name":"john",
      "description":"im 22",
      "email":"123@gmail.com"
   },
   {  
     "name":"jessie",
     "description":"im 12",
     "email":"1234@gmail.com"
   },
   {  
     "name":"jackson",
     "description":"im 32",
     "email":"1235@gmail.com"
   },
   {  
     "name":"jason",
     "description":"im 27",
     "email":"1236@gmail.com"
   }
]

this is my json data Im trying to make the name the card title, the email the sub title, and the description the body.

You can use Map to iterate item in the array, If you target web you can use Div instead of View and P instead of Text

Data.map((item)=>{
   return (
    <View>
        <Text> {item.name} </Text>
        <Text> {item.title} </Text>
        <Text> {item.descreption} </Text>
      </View>
    );
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM