gpt4 book ai didi

reactjs - 弯曲方向 : 'row' is not working in FlatList

转载 作者:行者123 更新时间:2023-12-03 13:42:49 26 4
gpt4 key购买 nike

我试图获得低于输出的结果,但 flexDirection: 'row' 无法正常工作。请任何人都可以解释一下如何获得以下输出。如有任何帮助,我们将不胜感激。

**所需输出:** enter image description here

我的输出: enter image description here

我的代码是:

_renderItem(rowData) {
return(
<View style={{flex: 1, flexDirection: 'row', flexWrap: 'wrap'}}>
<View style={{margin: 2, width: '24%', backgroundColor: '#fff', borderWidth: 1, borderColor: '#aaa'}}>
<TouchableOpacity activeOpacity={0.9} style={{height: 190}}>
<Image source={{uri: rowData.item.images[0].src}} style={{height: '100%', width: '100%'}}/>
</TouchableOpacity>
<View style={{padding: 5}}>
<TouchableOpacity activeOpacity={0.9} style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<View>
<CapitalizedText style={{color: '#666', fontSize: 14}}>{rowData.item.title}</CapitalizedText>
<Text style={{fontSize: 15, color: '#666', justifyContent: 'center', alignItems: 'center'}}>{'₹' + rowData.item.variants[0].price}</Text>
</View>
<Icon size={24} color="#aaa" name="turned-in-not" />
</TouchableOpacity>
<CapitalizedText style={{fontSize: 14, color: '#bbb'}}>Printed Top</CapitalizedText>
</View>
</View>
</View>
);
}
render() {
return(
<View>
{
this.state.product_detail.length <= 0 ?
<ActivityIndicator color = '#bc2b78' size = "large" style={{alignItems: 'center', justifyContent: 'center'}} />
:
<FlatList
keyExtractor = {( item, index ) => index }
data = { this.state.product_detail }
renderItem = {(rowData) => this._renderItem(rowData)}
ListFooterComponent = { this._render_Footer }
/>
}
</View>
);}

谢谢。

最佳答案

使用 flatList 中的 numColumns 属性将 flatList 的文本项对齐在一行中,例如

let numColumns=5;
<FlatList numColumns={numColumns}/>

关于reactjs - 弯曲方向 : 'row' is not working in FlatList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50187009/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com