首页 > 解决方案 > can I make the array containing 5 names display Vertically Using the stylesheet in react native??

问题描述

render() {
var myloop = [
      "Karan " + "\n",
      "bharat " + "\n",
      "parth " + "\n",
      "dharmil " + "\n",
      "raj "
    ];
return(
<Text>{myloop}</Text>
)

I know i can display it by using \n concatenation but i want to do it using stylesheet

标签: react-native

解决方案


这可能对您有所帮助:

 var myloop = [
            "Karan ",
            "bharat",
            "parth",
            "dharmil",
            "raj"
        ];

        return (
            <View style={{ width: '100%', height: '100%' }}>
                <View>
                    {
                        myloop.map((value, index) => {
                            return <Text>{value}</Text>
                        })
                    }
                </View>
            </View>
        )

推荐阅读