解决FlatList不完全可见
我使用React Native FlatList有一个奇怪的问题(sectionList和ListView出现同样的问题)
当Flatlist是屏幕上唯一的组件时,它可以正常工作 . 但是当在其之前渲染其他组件时,例如一个文本组件,然后列表的最后一项不可滚动 .
示例代码:
import React, { Component } from 'react';
import { Modal, Text, TouchableHighlight, View, Alert, FlatList } from 'react-native';
export default class ModalExample extends Component {
data = [];
constructor(props) {
super(props);
this.state = {};
for(var i = 0; i < 200; i++)
{
this.data.push('test string' + i);
}
}
render() {
return (
<View>
<Text>This is a test</Text>
<Text>This is a test</Text>
<Text>This is a test</Text>
<FlatList
data={this.data}
renderItem={({ item }) => <Text>{item}</Text>}
/>
</View >
);
}
}
解决
结果是flex:1就是答案 . 诀窍是将它一直添加到app.js

浙公网安备 33010602011771号