如何在react-native中使文本的某些部分可单击,而使部分具有不同的文本颜色

Moh*_*zad 4 android ios react-native

我正在尝试使文本的某些部分具有不同的颜色并可以点击

这是我的代码:

<Text style = {styles.term_service}>By signing up, you agree to Terms of Service and Privacy Policy.</Text>
Run Code Online (Sandbox Code Playgroud)

我想使“服务条款”和“隐私权政策”可点击,并使用不同的颜色。

Moh*_*lil 6

您可以使用嵌套文本文档也可以Text接受onPress 文档

<Text style = {styles.term_service}>By signing up, you agree to Terms of Service and <Text onPress={()=> someAction()} style = {{ color: '#fff' }}>Privacy Policy.</Text></Text>
Run Code Online (Sandbox Code Playgroud)