javascript - Flexbox 生成器在我的反应应用程序中显示不好
问题描述
我正在测试https://yogalayout.com/playground并创建了该模板:
import React, {Component} from 'react';
import {View} from 'react-native';
export default class MyLayout extends Component {
render() {
return (
<View style={{
flex: 1,
width: 500,
height: 500,
justifyContent: 'space-between',
backgroundColor: 'red',
}}>
<View style={{
flex: 1,
width: 100,
height: 100,
backgroundColor: 'blue',
}} />
<View style={{
flex: 1,
width: 100,
height: 100,
backgroundColor: 'green',
}} />
<View style={{
flex: 1,
width: 100,
height: 100,
backgroundColor: 'purple',
}} />
</View>
);
}
};
我希望有这样的结果:
相反,我有这个:
什么会破坏我的 flexbox 布局?
解决方案
默认flexDirection
在column
React Native 中。因此,尝试将其设置为row
在您的容器中View
。
<View style={{
flex: 1,
width: 500,
height: 500,
justifyContent: 'space-between',
backgroundColor: 'red',
flexDirection: "row"
}}>
.
.
.
推荐阅读
- json - PayPal 快递结帐 JSON 格式错误
- angular - Angular 7嵌套表单数组在点击时不起作用
- linux - 在 Ansible Tower 中使用事实过滤库存的语法是什么?
- javascript - javascript转换阿塞拜疆字母大“İ”(英文“I”)错了吗?
- c# - 单元测试控制器模拟 ISession
- assembly - MIPS 汇编器更改数组
- javascript - 带有 multipart/form-data 和 @ApiImplicitBody 的 Swagger 文档
- php - 单击时如何在ajax中刷新当前弹出窗口
- java - webflux spring boot 应用程序的过滤器,返回 ResponseEntity
- html - 最小宽度和宽度适合内容不适用于文本区域或输入