如何在< Text>中插入换行符React Native中的组件? [英] How can I insert a line break into a <Text> component in React Native?
本文介绍了如何在< Text>中插入换行符React Native中的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在React Native的Text组件中插入新行(例如\ r \ n,< br/>).
I want to insert a new line (like \r\n, <br />) in a Text component in React Native.
如果我有
<text><br />
Hi~<br >
this is a test message.<br />
</text>
然后React Native渲染Hi~ this is a test message.
Then React Native renders Hi~ this is a test message.
是否可以像这样渲染文本以添加新行:
Is it possible render text to add a new line like so:
Hi~
this is a test message.
推荐答案
这应该做到:
<Text>
Hi~{"\n"}
this is a test message.
</Text>
这篇关于如何在< Text>中插入换行符React Native中的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文