我希望州值{ province }为style ={ styles.text }中设置的不同颜色。谁能给我一些关于如何做到这一点的想法?
<Text style = {[ styles.text ]}>
Province - { province }
</Text>
发布于 2021-10-06 10:47:17
React Native支持嵌套的Text
组件。你可以这样做:
<Text style = {[ styles.text ]}>
Province -
<Text style={{color: /ANY COLOR/}} >
{ province }
</Text>
</Text>
希望这对你有用。
发布于 2021-10-06 10:45:47
要实现这一点,您必须将省份放在它自己的文本标记中。示例:
<Text style = {[ styles.text ]}>
Province - <Text style={styles.YourStyle}>{province}</Text>
</Text>
发布于 2021-10-06 10:46:36
使用视图并将两个元素放入两个元素中,每个元素都有不同的样式类,而不是将所有文本包装在同一个元素中:
<View style={{flexDirection:'row'}}>
<Text style={styles.text}>Province - </Text>
<Text style={styles.otherText}>{province}</Text>
</View>
https://stackoverflow.com/questions/69464010
复制相似问题