0

我需要禁用父级FlatList的滚动(滚动将通过按下按钮来实现)并激活子级的滚动FlatListscrollEnabled={false}由于我为父级设置的事实,FlatList滚动不适用于子级Flatlist。如何解决这个问题呢?

const data = [
  { type: 'list', data: ['Apple', 'Banna', 'Pear', 'Orange', 'Grape', 'Pineapple']},
  { type: 'list', data: ['Bike', 'Car', 'Train', 'Plane', 'Boat', 'Rocket']}
];

return (
  <FlatList
    data={data}
    keyExtractor={item => item.id}
    renderItem={({item}) => {
      return <FlatList
        data={item.data}
        keyExtractor={item => item.id}
        numColumns={item.data.length} // horizontal
        renderItem={({item}) => (
            <View style={{width: width, height: 50, alignItems: 'center', justifyContent: 'center'}}>
              <Text>{item}</Text>
            </View>
          )
        }
        pagingEnabled
      />
    }}
    horizontal
    pagingEnabled
    scrollEnabled={false}
  />
);

示例代码小吃

4

0 回答 0