【发布时间】:2017-09-07 19:00:42
【问题描述】:
我正在使用 React Native 的新 FlatList 组件。我正在使用它来呈现一个水平列表,但是当使用内置的ItemRenderComponent 时,它会在每个项目下方而不是在它们之间显示分隔符。
有办法改变吗?
interface State {
dataSource: WhosOutByPolicy[];
}
interface Props {
data: WhosOutByPolicy[];
}
class WhosOutParentCell extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { dataSource: props.data };
}
renderSeparator = () => {
return (
<View
style={{
height: 100,
width: 3,
backgroundColor: "#D81458"
}}
/>
);
};
render() {
return (
<View style={styles.container}>
<FlatList
data={this.state.dataSource}
horizontal={true}
renderItem={({ item }) => (
<WhosOutUsersInPolicyCell data={item} />
)}
keyExtractor={item => item.policyDispalyName}
ItemSeparatorComponent={this.renderSeparator}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#EFEFEF"
}
});
export default WhosOutParentCell;
【问题讨论】:
-
为您的渲染、renderRow 和 renderSeperator 放置代码。您希望我们如何知道您的问题??
-
请用您的代码更新您的问题。
-
@KhalilKhalaf,我用相关代码更新了问题
-
@VahidBoreiri - 我添加了它
-
我担心 hieght:100 的东西,你也可以添加一个打印屏幕吗?你还有很多物品和“有”使用平面列表吗?为什么不使用 listView?
标签: react-native react-native-flatlist