反应本地弹性指导:' row'不起作用
我试图将这些项目名称列为一排 - 将它们放置在水平上,但它不起作用。我不知道原因。我真的很感谢您的帮助
const Text = () => {
const Menu = [
{'id':1,
'menuName':'whatever',
},
{'id':2,
'menuName':'whatever',
},
{'id':3,
'menuName':'whatever...',
},
];
return (
<View style={styles.container}><Text
>Test
</Text>
{Menu.map((menuItems) => (
<View style={styles.menuName} key={menuItems.id} >
<Text>{menuItems.menuName}</Text>
</View>
))}
</View>
)
}
const styles = StyleSheet.create({
container :{
flex:1
},
menuName:{
flexDirection: 'row',
height: 48,
width: '100%',
borderWidth: 1,
padding: 10,
}
});
I am trying to list these itemsNames into a row- put them horizontaly, but it is not working. I can't figure out the reason why. I would really appreciate some help
const Text = () => {
const Menu = [
{'id':1,
'menuName':'whatever',
},
{'id':2,
'menuName':'whatever',
},
{'id':3,
'menuName':'whatever...',
},
];
return (
<View style={styles.container}><Text
>Test
</Text>
{Menu.map((menuItems) => (
<View style={styles.menuName} key={menuItems.id} >
<Text>{menuItems.menuName}</Text>
</View>
))}
</View>
)
}
const styles = StyleSheet.create({
container :{
flex:1
},
menuName:{
flexDirection: 'row',
height: 48,
width: '100%',
borderWidth: 1,
padding: 10,
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因。
的 - 方向将应用于查看(容器)
请进行以下样式更改。
要更多地研究flex href =“ https://reaectnative.dev/docs/flexbox” rel =“ nofollow noreferrer”> link。
Reason for not to work.
In order to arrange the items in a view, you need to set flexDirection='row' in your case items inside your View(Container) needed to be arranged horizontally so the flex-direction will be applied to View(Container)
Please make the following changes in style it will work.
To study more about flex please follow this link.