在邊欄中,我使用的是 "@react-navigation/drawer": "^5.12.5"
如何將 DrawlerItems 中的標簽包裝到下一行?
const itemStyle = {
marginLeft: 0,
borderBottomColor: '#D9DBE9',
borderBottomWidth: 1,
marginVertical: 0,
paddingBottom: 10,
paddingTop: 10,
width: '100%',
};
const labelStyle = {
fontSize: 16,
fontWeight: '600'
}
<DrawerContentScrollView {...props} style={{ flex: 1 }}>
<View>
<DrawerItem
label={'label 1'}
labelStyle={{ ...labelStyle, backgroundColor: 'red' }}
style={itemStyle}
/>
<DrawerItem
label={'long label 2'}
labelStyle={{ ...labelStyle, backgroundColor: 'yellow' }}
style={itemStyle}
/>
</View>
</DrawerContentScrollView>
uj5u.com熱心網友回復:
這是因為DrawerItem檔案有numberOfLines={1}
解決方法可能就像您可以通過洗掉numberOfLines當前從庫中更新DrawerItem檔案它具有以下代碼
<Text
numberOfLines={1} // this line making the label single liner
allowFontScaling={allowFontScaling}
style={[
{
color,
fontWeight: "500",
},
labelStyle,
]}
>
{label}
</Text>
另一種方法是使用類似的功能,例如
label={({focused, color}) => (
<Text style={{color}}>Your Label</Text>
)}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/467115.html
