我有这样的东西

<View>
  <Text>By clicking this I accept </Text>
  <TouchableHighlight>
    <Text>Terms and Conditions, </Text>
  </TouchableHighlight>
  <TouchableHighlight>
    <Text>Privacy Policy</Text>
  </TouchableHighlight>
</View>

它看起来像这样
By clicking this I accept
Terms and Conditions
Privacy Policy

或者如果我连续显示它,它看起来像这样(|显示屏幕的边框)
|                                        |
| By clicking this I accept Terms and Con|ditions, Privacy Policy
|                                        |

我希望它看起来像
|                                       |
| By clicking this I accept Terms and   |
| Conditions, Privacy Policy            |

我的意思是,如果屏幕上没有合适的单词,则将其放在下一行。就像多行文字一样,但是具有多个文字和可触摸的高光。这有可能吗?

最佳答案

尝试这样的事情。

<Text>
    <Text>By clicking this I accept </Text>
    <Text onPress={() => console.log('terms pressed')} style={{color: 'red'}}>Terms and Conditions</Text>
    <Text>,</Text>
    <Text onPress={() => console.log('privacy pressed')} style={{color: 'red'}}>Privacy Policy</Text>
</Text>

只需将console.log替换为您希望处理单击的任何功能的参考即可。

关于react-native - 在React-native中,如何制作多行文本?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40135328/

10-11 11:17