[英]How do you arrange shapes in React Native?
好吧,这是你的图片的快速版本。
import React from "react"
import { StyleSheet, View } from "react-native"
export const Test = () => {
return (
<View style={styles.container}>
<View style={styles.row}>
<View style={[styles.square]} />
<View style={[styles.square]} />
<View style={[styles.square, { backgroundColor: "yellow" }]} />
<View style={[styles.square, { backgroundColor: "turquoise" }]} />
</View>
<View style={styles.row}>
<View style={[styles.square, { backgroundColor: "red" }]} />
<View style={[styles.square, { backgroundColor: "blue" }]} />
<View style={[styles.square, { backgroundColor: "green" }]} />
<View style={[styles.square, { backgroundColor: "violet" }]} />
<View style={[styles.square, { backgroundColor: "yellow" }]} />
</View>
<View style={[styles.square, { backgroundColor: "lightgrey", height: 25, width: 300 }]} />
</View>
)
}
const styles = StyleSheet.create({
container: {
display: "flex",
},
row: {
flexDirection: "row",
},
square: {
width: 60,
height: 60,
},
})
这产生了以下观点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.