javascript - 如何在ios中的react-native-tableview中显示数组数据

标签 javascript ios react-native

我正在使用react-native-tableview来显示数据列表。

这是我的代码

    <TableView style = {styles.usersTableViewStyle}
                   allowsToggle={true}
                   allowsMultipleSelection={true}
                   tableViewStyle={TableView.Consts.Style.Plain}
                   tableViewCellStyle={TableView.Consts.CellStyle.Subtitle}
                   onPress={(event) => console.log(event)}>

             <Section label="List" style={styles.Section}>
                    <Item> Apple </Item>
                    ....
             </Section>

    </TableView>

现在带有虚拟数据的简单表格即将出现。

我有两个问题

  1. 我有一个数组,我想显示表格中的全部内容。我们怎样才能实现这一目标?

  2. 无法增加 css 中的行高、节高。如何增加单元高度?

如有任何帮助,我们将不胜感激。提前致谢。

最佳答案

我找到了第一个问题的答案。 如何在tableview中显示数组值?

通过此代码,我们可以在react-native-tableview中显示数组值。

<TableView style = {styles.fruitsTableViewStyle}
               allowsToggle={true}
               allowsMultipleSelection={true}
               tableViewStyle={TableView.Consts.Style.Plain}
               tableViewCellStyle={TableView.Consts.CellStyle.Subtitle}
               onPress={(event) => console.log(event)}>

          <Section label = 'List'>
               {
                   fruitsArray.map(function(name, index) {
                        return <Item key = {index} label = {name}>
                                     {name}
                               </Item>
                        )
               }

          </Section>
</TableView>

关于javascript - 如何在ios中的react-native-tableview中显示数组数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44542083/

相关文章:

javascript - 使用 javascript 或 jquery 验证价格范围

javascript - 在 processing.js 中填充图像

ios - 如何在 xcode 4.2 中将 iPhone 应用程序升级到 iPad 应用程序?

react-native - 来自 React Native 的 TextInput 不显示输入的文本

javascript - 在字符串连接内执行映射函数

javascript - 如何选择 Javascript/Google Apps 脚本中的最后一个 JSON 条目?

iphone - iOS - 如何不在屏幕上显示导航栏?

ios - 设置CoreData NSManagedObjectContext线程优先级

reactjs - 无法更改 native 基本选项卡的高度

react-native - 为什么命令 npm install -g expo-cli 不起作用