简体   繁体   English

React Native,Flatlist 自定义每行 2 个项目

[英]React Native, Flatlist customize with 2 item per row

How can I make my flatlist look like this?我怎样才能让我的平面列表看起来像这样? Is there any prop for this or which style I need to use to do that?是否有任何道具或我需要使用哪种风格来做到这一点?

在此处输入图片说明

You have to use the numColumns prop of the flat list which would display the items in columns您必须使用平面列表的 numColumns 道具来显示列中的项目

https://reactnative.dev/docs/flatlist#numcolumns https://reactnative.dev/docs/flatlist#numcolumns

You can provide extra property numColumns={2} in your Flatlist component to get two items each row.您可以在 Flatlist 组件中提供额外的属性numColumns={2}以每行获取两个项目。

here is a wonderful tutorial by Spencer: https://www.reactnativeschool.com/react-native-flatlist-grid这是 Spencer 的精彩教程: https : //www.reactnativeschool.com/react-native-flatlist-grid

<FlatList
      numColumns={2}
     ....................
    />

Render your data and make numColumns={2}呈现您的数据并使numColumns={2}

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

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