[英]React Native Text Components: How to combine a url and other strings?
I have a url format like http://abc.go.com
or http://abc.go.com
.我有一个 url 格式,如
http://abc.go.com
或http://abc.go.com
。
In React Native, i have a <Text>...</Text>
to contain some child <Text>...</Text>
在 React Native 中,我有一个
<Text>...</Text>
来包含一些子<Text>...</Text>
My structure is below :我的结构如下:
<Text>
<Text>
My homepage is a link like :
</Text>
<Text>
http://abc.go.com
</Text>
<Text>
Welcome Welcome
</Text>
</Text>
In small size Device to check, it shows the below result :在要检查的小尺寸设备中,它显示以下结果:
My homepage is a link like : http://
abc.go.com Welcome Welcome
this result is not my want.这个结果不是我想要的。 (If one line is not enough to show url) I want the result should be:
(如果一行不足以显示网址)我希望结果应该是:
My homepage is a link like :
http://abc.go.com Welcome Welcome
My question is how to combine of a whole url with 'http://' prefix with other strings?我的问题是如何将整个 url 与 'http://' 前缀与其他字符串组合?
My environment is React Native, JavaScript我的环境是 React Native、JavaScript
A simple solution could be the following一个简单的解决方案可能如下
<Text>
<Text style={{flex:1}}>
My homepage is a link like :
</Text>
<Text>
http://abc.go.com
</Text>
<Text>
Welcome Welcome
</Text>
</Text>
But this would make但这会让
My homepage is a link like:
我的主页是一个链接,如:
always take up a whole line on screen which might not suite all use cases if you would give a bit more detailed description I could think of a more universal solution.总是在屏幕上占据一整行,如果你能给出更详细的描述,我可以想到一个更通用的解决方案,这可能不适合所有用例。
You can force a line break by inserting the newline character at the position where you don't want another text to appear.您可以通过在不希望出现其他文本的位置插入换行符来强制换行。
<Text>
<Text>
`My homepage is a link like :{'\r\n'}`
</Text>
<Text>
http://abc.go.com
</Text>
<Text>
Welcome Welcome
</Text>
</Text>
PS I could not entirely reproduce your error. PS 我无法完全重现您的错误。 In my case the separate inner
Text
components were all in a separate line.在我的例子中,单独的内部
Text
组件都在一个单独的行中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.