【问题标题】:Displaying contents of array on multiple lines in React Native在 React Native 中多行显示数组的内容
【发布时间】:2016-07-25 19:24:47
【问题描述】:

我有一个字符串数组,我想在 React Native for iOS 的屏幕上多行显示。在我的文本视图中,我目前只有一行代码:

<Text style={styles.text}>
  {this.state.selectData}
</Text>

我想每行显示 selectData 数组的 3 个元素,但我不知道如何执行它。

【问题讨论】:

    标签: arrays react-native


    【解决方案1】:

    类似的东西

    render(){
       <View>
         {this.state.selectData.map((value, index) => {
             return (
                 <Text key={index}>
                    {value}
                 </Text>
              );
             })
          }
         </View>
        );
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-31
      • 1970-01-01
      • 2020-03-28
      • 1970-01-01
      • 1970-01-01
      • 2020-03-07
      • 2020-01-25
      • 2021-09-03
      相关资源
      最近更新 更多