如何在 <Text> 中插入换行符?React Native 中的组件? [英] How can I insert a line break into a <Text> component in React Native?

查看:30
本文介绍了如何在 <Text> 中插入换行符?React Native 中的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 React Native 的 Text 组件中插入一个新行(如 , <br/>).

I want to insert a new line (like , <br />) in a Text component in React Native.

如果我有:

<text>
<br />
Hi~<br />
this is a test message.<br />
</text>

然后React Native渲染Hi~这是一条测试信息.

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~{"
"}
this is a test message.
</Text>

这篇关于如何在 &lt;Text&gt; 中插入换行符?React Native 中的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆