React native 如何防止英语中的断字?
这似乎是一个显而易见的问题,但我不知道如何防止React原生文本组件在不适合容器宽度的情况下破坏单个单词,同时保持单词的一般包装。这似乎是一个奇怪的默认打破的话-我如何防止它 下面是一些示例代码:React native 如何防止英语中的断字?,react-native,React Native,这似乎是一个显而易见的问题,但我不知道如何防止React原生文本组件在不适合容器宽度的情况下破坏单个单词,同时保持单词的一般包装。这似乎是一个奇怪的默认打破的话-我如何防止它 下面是一些示例代码: <View style={{ width: 35, height: 35, }}> <Text style={{ flex: 1, // flexWrap: "nowrap", // did nothing
<View style={{
width: 35,
height: 35,
}}>
<Text
style={{
flex: 1,
// flexWrap: "nowrap", // did nothing
// flexShrink: 1, // did nothing
fontSize: 10,
lineHeight: 16,
// whiteSpace: "nowrap", // did nothing
}}
>Hereisareallylongwordina block with shorter words.</Text>
</View>
这里是一个真正的长单词和短单词块。
请使用:
空白:“nowrap”似乎没有任何作用-它应该在元素上吗?从React Native 0.64.x开始,
whiteSpace
不是有效的样式属性。此外,CSS中的空白:“nowrap”
不影响单个单词,这似乎是OP关注的问题,例如,当容器太窄时,单个单词被破坏。文本组件有一个textBreakStrategy
prop,但它不能防止单词被破坏。