日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

ScrollView child layout ([alignItems]) 错误

發(fā)布時間:2025/4/5 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ScrollView child layout ([alignItems]) 错误 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

用React Native里的ScrollView組件,給ScrollView直接加了justifyContent或alignitems屬性后會報錯。

<ScrollView style={{alignItems:'center'}}>
<FlatList
data={this.state.sellData}
renderItem={({item})=><SellItem ordernum={item.orderNumber} time={item.time} memberid={item.memberId}
number={item.number} price={item.price} total_amount={item.total_amount}
sellCallBack={
()=>{
this.sellDba(item.orderId)
}
}
/>}
/>
</ScrollView>

報錯(ScrollView child layout ([“alignitems”, “justifyContent”]) must be applied through the contentContainerStyle prop)如下:

(似乎是reactnative版本升級后的問題)問題原因是scrollView和flatlist之類的組件不支持直接添加這兩個屬性,解決方法是給組件添加contentContainerStyle屬性,這些樣式會應(yīng)用到一個內(nèi)層的內(nèi)容容器上,所有的子視圖都會包裹在內(nèi)容容器內(nèi),在這個屬性后面指定對應(yīng)的樣式即可:

<ScrollView contentContainerStyle={{alignItems:'center'}}>
<FlatList
data={this.state.sellData}
renderItem={({item})=><SellItem ordernum={item.orderNumber} time={item.time} memberid={item.memberId}
number={item.number} price={item.price} total_amount={item.total_amount}
sellCallBack={
()=>{
this.sellDba(item.orderId)
}
}
/>}
/>
</ScrollView>

轉(zhuǎn)載于:https://blog.51cto.com/13238147/2371910

總結(jié)

以上是生活随笔為你收集整理的ScrollView child layout ([alignItems]) 错误的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。