React Native 为 <Text> 中的单个单词添加粗体或斜体场地 [英] React Native add bold or italics to single words in <Text> field
本文介绍了React Native 为 <Text> 中的单个单词添加粗体或斜体场地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将文本字段中的单个单词设为粗体或斜体?有点像这样:
How do I make a single word in a Text field bold or italics? Kind of like this:
<Text>This is a sentence <b>with</b> one word in bold</Text>
如果我为粗体字符创建一个新的文本字段,它会将其分隔到另一行,因此这肯定不是这样做的方法.这就像创建一个 <p > 标签内的 <p > 标记只是为了使一个词加粗.
If I create a new text field for the bold character it will separate it onto another line so that's surely not the way to do it. It would be like creating a < p > tag within a < p > tag just to make one word bold.
推荐答案
您可以将
用作其他文本组件的容器.这是示例:
You can use <Text>
like a container for your other text components.
This is example:
...
<Text>
<Text>This is a sentence</Text>
<Text style={{fontWeight: "bold"}}> with</Text>
<Text> one word in bold</Text>
</Text>
...
这是一个示例.
这篇关于React Native 为 <Text> 中的单个单词添加粗体或斜体场地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文