ket*_*rni 3 react-native react-native-flexbox
在HTML中,我可以通过实现
<span style="background-color:red">ketan</span>
Run Code Online (Sandbox Code Playgroud)
但是在本机中如何实现此功能,以便仅将颜色应用于文本。
如果希望背景色仅包含文本,则可以使用以下方法:
<Text style={{backgroundColor: 'blue', alignSelf: 'flex-start'}}>
Ketan
</Text>
Run Code Online (Sandbox Code Playgroud)
只需根据需要更改alignSelf即可,如果您不希望文本占据容器的整个宽度,则需要设置此属性
在本机反应中,您有用于Text显示文本的组件。
要设置 的颜色Text,您可以使用color它的属性
<Text style={{color:'#ff0000'}}>Your Text</Text>
Run Code Online (Sandbox Code Playgroud)
对于该文本的背景颜色,您可以使用View和 比backgroundColor设置View
| 归档时间: |
|
| 查看次数: |
7396 次 |
| 最近记录: |