Css 反应本机-平面列表不滚动

Css 反应本机-平面列表不滚动,css,reactjs,react-native,flexbox,react-native-flatlist,Css,Reactjs,React Native,Flexbox,React Native Flatlist,我正在实现的水平模式,但它没有响应。我尝试了以下方法,但没有成功: 一切都消失了 flexGrow:1 收视 添加边距/填充 以下是平面列表的代码: return ( <View > { this.state.dataSource.length < 1 ? ( <Text>did not get person</Text> ) : ( <View><FlatLis

我正在实现的水平模式,但它没有响应。我尝试了以下方法,但没有成功:

一切都消失了 flexGrow:1 收视 添加边距/填充 以下是平面列表的代码:

   return (
    <View >
    {
      this.state.dataSource.length < 1 ? (
        <Text>did not get person</Text>
      ) : (
      <View><FlatList
        showsHorizontalScrollIndicator={false}
        horizontal
        data={this.state.dataSource}
        renderItem={this.renderItem}
        keyExtractor={item => item.id}
      />
      </View>)

}

如果为容器视图提供flex:1,它将按照您的需要工作

  <View style={styles.flex1} >
     <FlatList
      showsHorizontalScrollIndicator={false}
      horizontal
      data={this.state.dataSource}
      renderItem={this.renderItem}
      keyExtractor={item => item.id}
    />
   </View>

const styles = StyleSheet.create({  
    flex1: {  
        flex: 1,  
    },  
.... 
})  

如果您为容器视图提供flex:1,它将按照您的需要工作

  <View style={styles.flex1} >
     <FlatList
      showsHorizontalScrollIndicator={false}
      horizontal
      data={this.state.dataSource}
      renderItem={this.renderItem}
      keyExtractor={item => item.id}
    />
   </View>

const styles = StyleSheet.create({  
    flex1: {  
        flex: 1,  
    },  
.... 
})  
这可能会有帮助

return (
  <View style={{ flex: 1 }}>
    {this.state.dataSource.length < 1 ? (
      <Text>did not get person</Text>
    ) : (
      <FlatList
        showsHorizontalScrollIndicator={false}
        horizontal
        data={this.state.dataSource}
        renderItem={this.renderItem}
        keyExtractor={(item, index) => index.toString()}
      />
    )}
  </View>
);
这可能会有帮助

return (
  <View style={{ flex: 1 }}>
    {this.state.dataSource.length < 1 ? (
      <Text>did not get person</Text>
    ) : (
      <FlatList
        showsHorizontalScrollIndicator={false}
        horizontal
        data={this.state.dataSource}
        renderItem={this.renderItem}
        keyExtractor={(item, index) => index.toString()}
      />
    )}
  </View>
);

为平面列表提供flex:1将使您的屏幕变为空白。试着用一个简单的列表来完成这项工作。上述视图将为平面列表提供空间,以适应屏幕。

为平面列表提供flex:1将使屏幕变为空白。试着用一个简单的列表来完成这项工作。上述视图将为平面列表提供空间,以适应屏幕