簡體   English   中英

如何使用 nativebase 創建水平列表

[英]How to create a horizontal list with nativebase

我正在使用 react-native 作為我的前端庫的 nativebase 進行移動應用程序開發。 我想知道如何在 nativebase 中實現水平列表項

我知道我可以使用 FlatList 但我對 nativebase 列表組件感興趣

// import components from native base
import { List, ListItem } from "native-base";

// lets assume your you have this array
let data=[
  {
    pet: 'gsd'
  },
  {
    pet: 'husky'
  },
  {
    pet: 'rotweiler'
  }
];

// inside you render method return this component

return (
   <List horizontal={true} dataArray={data} // your array should go here
         renderRow={pet => (
             <ListItem>
                // if you want you can add a card item here, But I'm adding a simple text
                <Text> {pet.name}
                </Text>
             </ListItem>
         )}>
   </List>

)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM