我想插入一个新行(如\r\n,
)在React Native中的文本组件中。
如果我有:
Hi~
this is a test message.
然后反应原生渲染
是否可以渲染文本以添加新行,如下所示:
Hi~
this is a test message.
发布于 2015-09-09 20:55:31
这应该可以做到这一点:
Hi~{"\n"}
this is a test message.
发布于 2016-11-21 14:31:10
您还可以执行以下操作:
{`
Hi~
this is a test message.
`}
在我看来更简单,因为您不必在字符串中插入内容;只需将它换行一次,它就会保留所有的换行符。
发布于 2018-05-17 17:47:00
使用:
{`Hi,\nCurtis!`}
结果:
嗨,
柯蒂斯!
https://stackoverflow.com/questions/32469570
复制相似问题