文本表现得像跨度React Native

时间:2018-07-15 23:59:04

标签: reactjs react-native

我该如何为我的标签“ Encontrados”表现得像个span。我的意思是,它只占用必要单词的空格,此空间可以随其他单词(例如Adopcion或Perdidos)而变化,但是我想要的行为相同,我无法使其正常工作。这是我的代码:

<View><Text style={styles.tag}>{tagType}</Text></View>

tag: {
        borderRadius: 6,
        borderColor: "#999",
        borderWidth: 2,
        padding: 5,
        marginBottom: 10,
        fontWeight: "600",
        color: "#999"
    }

这看起来像是一个简单的问题,但是我是新来的人,在网络上找不到解决方案,谢谢阅读。

enter image description here

1 个答案:

答案 0 :(得分:0)

我用以下代码解决了它:

<View style={styles.contentView}>
    <Text style={{ borderColor: "#999", borderWidth: 2, borderRadius: 6, padding: 9}}>
        <Text style={styles.tagName}>
             {tagType}
        </Text>
    </Text>
 </View>

tagName: {
  color: "#999"
},
contentView: {
   paddingLeft: 10,
   flex: 1,
   flexDirection:'row',
   flexWrap:'wrap',
   marginBottom: 15
}