React native 不同宽度的多行文字?

React native 不同宽度的多行文字?,react-native,react-native-text,React Native,React Native Text,是否可以生成多行文字,其中行的长度在React Native中不同 示例地址(可以是任何字符串)中相同长度行的情况: const address = 'Circular Quay, Alfred St, Sydney 2021 NSW Alexandria'; return ( <View style={{width: 80}}> <Text>{address}</Text> </View> ) const地址=

是否可以生成多行文字,其中行的长度在React Native中不同

示例地址(可以是任何字符串)中相同长度行的情况:

const address = 'Circular Quay, Alfred St, Sydney 2021 NSW Alexandria';
return ( 
    <View style={{width: 80}}>
        <Text>{address}</Text>
    </View>
)
const地址='2021年新南威尔士州亚历山大市悉尼阿尔弗雷德街环形码头';
报税表(
{地址}
)
预期结果:




谢谢

您可以通过在文本样式中应用不同的宽度来实现这一点

<Text style={{width='200'}}>Text 1</Text>
<Text style={{width='100'}}>Text 2</Text>
Text 1
文本2

您的问题的解决方案可以是文本组件中的文本对齐道具

<View style={{width: 80}}>
    <Text style={{ textAlign:'center'}}>{address}</Text>
</View> 

{地址}

不幸的是,这不起作用,因为a不知道从哪里将字符串剪切成两个不同的字体,因为它不是等距字体。重要的是,我只有一个字符串,而不是像您的示例中那样有两个。更新了问题!您可以使用address.split(“,”)并将前两项放在a中,将第三项放在另一个中