如何设置FlatList禁止滚动

来源:7-

lcc_zcq

2018-12-27

如何设置FlatList禁止滚动

写回答

1回答

CrazyCodeBoy

2018-12-27

试试这个属性哈:scrollEnabled=false

具体可参考:

https://facebook.github.io/react-native/docs/scrollview#scrollenabled

参考代码:

<FlatList
    data={store.projectModels}
    renderItem={data => this.renderItem(data)}
    keyExtractor={item => "" + item.item.id}
    scrollEnabled={false} //禁止滚动
    refreshControl={
        <RefreshControl
            title={'Loading'}
            titleColor={theme.themeColor}
            colors={[theme.themeColor]}
            refreshing={store.isLoading}
            onRefresh={() => this.loadData()}
            tintColor={theme.themeColor}
        />
    }
    ListFooterComponent={() => this.genIndicator()}
    onEndReached={() => {
        console.log('---onEndReached----');
        setTimeout(() => {
            if (this.canLoadMore) {//fix 滚动时两次调用onEndReached https://github.com/facebook/react-native/issues/14015
                this.loadData(true);
                this.canLoadMore = false;
            }
        }, 100);
    }}
    onEndReachedThreshold={0.5}
    onMomentumScrollBegin={() => {
        this.canLoadMore = true; //fix 初始化时页调用onEndReached的问题
        console.log('---onMomentumScrollBegin-----')
    }}
/>


0
2
CrazyCodeBoy
回复
lcc_zcq
这个属性是OK的,跟平台无关。
2019-01-07
共2条回复

RN入门到进阶,打造高质量上线App

解锁React Native开发应用新姿势,React Native新版本热门技术

3170 学习 · 3256 问题

查看课程