【发布时间】:2021-02-26 00:19:43
【问题描述】:
我想从两个给定的数组中创建一个 2 x 2 的表。该表应如下所示:
我必须使用 ES6 中的“地图”功能。我的代码如下所示。
import React, {Component} from 'react';
import {Text, View} from 'react-native';
const array1 = ['1','2'];
const array2 = ['X','Y']
class Table extends Component{
render() {
return (
<View style={{borderStyle : 'solid',justifyContent : 'center' }}>
{array1.map((arr1) => (
<View>
{array2.map((arr2) => (
<View>
<Text>
{arr2} {arr1}
</Text>
</View>
))}
</View>
))
}
</View>
);
}
}
export default Table;
此时我得到的输出类似于 - X1 X2 Y1 Y2
我需要使用 flex。我该怎么办?
【问题讨论】:
-
为什么要弯曲?看看网格布局吧。
-
我需要使用 flex,它用于一个项目
-
OP需要使用flex,因为react-native只支持flex布局
-
如果结果位置固定为奇偶数,如何在数组上生成并排序
标签: javascript css ecmascript-6 flexbox