【发布时间】:2021-04-24 09:44:07
【问题描述】:
我有以下 react-native 组件:
const TaskItem = () => {
return (
<>
<View
style={{
marginTop: 32,
marginHorizontal: 8,
display: 'flex',
flexDirection: 'row',
backgroundColor: 'red',
}}
>
<Text style={{ marginRight: 8 }}>
<Text style={{ backgroundColor: 'green' }}>Title:</Text>
</Text>
<Text>
<Text
style={{
fontWeight: 'bold',
color: '#000000',
backgroundColor: 'blue',
}}
numberOfLines={2}
>
Very long text Very long text Very long text Very long text Very long text
</Text>
</Text>
</View>
</>
);
};
它会产生以下屏幕(用于调试的背景颜色):
我想要的是:
- 蓝色文字不会溢出右侧的红色容器(尊重
marginHorizontal: 8) - 蓝色文本从左侧红色容器的开头开始(换行)
【问题讨论】:
标签: javascript css react-native react-native-paper