React Native:“自动”文本节点的宽度 [英] React Native: "Auto" width for text node
本文介绍了React Native:“自动”文本节点的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在视图中有一个text元素:
I have a text element inside a view:
< View>< Text> hello world foo bar< / Text>< ; / View>
作为Flex网格的一部分。
as part of a flex grid.
我要该视图具有基于内容的自动宽度,即文本的长度。
I want this view to have an auto width based on the content i.e. length of the text.
如何实现?
推荐答案
如果元素具有 alignSelf
属性,例如:
You can achieve this if element will have alignSelf
property, like:
alignSelf: 'flex-start'
或
alignSelf: 'center'
这篇关于React Native:“自动”文本节点的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文