【问题标题】:React Native - Random lines between list itemsReact Native - 列表项之间的随机行
【发布时间】:2018-09-08 03:58:32
【问题描述】:

我尝试使用 FlatList 和 map 函数生成条目列表,但条目之间出现随机线条(请参阅屏幕截图的蓝色部分)

这些是什么原因造成的,我该如何去除它们?

这是我的平面列表:

<FlatList
    data={TriageTransfertData[0].content[0].content}
    renderItem={({ item }) => (
         <View style={styles.subentryContainer}>
           <View style={styles.ttEntryFirst} />
           <View style={styles.ttEntryContentSub}>
             <Text style={styles.ttTextSub}>{item.text}</Text>
           </View>
         </View>
     )}
     keyExtractor={item => item.text} />

这里是样式:

subentryContainer: {
    flexDirection: 'row',
    width: '100%',
},
ttEntryFirst: {
    width: '2%',
    backgroundColor: Colors.Blue
},
ttEntryContentSub: {
    width: '98%',
    justifyContent: 'center',
    paddingLeft: responsiveWidth(2),
    paddingTop: 10,
    paddingBottom: 10,
    borderTopWidth: 1,
    borderColor: Colors.GreyLight
},

最后,这是一个屏幕截图(注意蓝色区域中不需要的线):

【问题讨论】:

    标签: android ios react-native react-native-flatlist


    【解决方案1】:

    我想你说的是ItemSeparatorComponent。它默认呈现在 FlatList 中,但您可以通过自定义组件或空白代码函数覆盖它。 这是简短的doc

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2021-12-09
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      • 2018-01-16
      • 1970-01-01
      • 2018-11-17
      相关资源
      最近更新 更多