简体   繁体   English

如何在 js 中循环遍历我的 json 数据以在我的 html 页面中制作卡片

[英]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.这是我的 json 数据我试图将名称设为卡片标题,将 email 设为副标题,将描述设为正文。

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您可以使用 Map 来迭代数组中的项目,如果您以 web 为目标,您可以使用 Div 而不是 View 和 P 而不是 Text

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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