ReactNative中的属性用法。
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity,
TextInput,
Image,
} from 'react-native';
/**
* 2、flex 属性
*/
let RnDemo = React.createClass({
render: function () {
return (
<View style={styles.container}>
<View style={styles.child1}></View>
<View style={styles.child2}></View>
</View>
);
}
});//创建样式
let styles = StyleSheet.create({
container: {
margin: 30,
width: 300,
height: 500,
backgroundColor: "yellow",
//默认主抽方向 column
//设置为横向
flexDirection: "row",
//设置主抽方法居中
justifyContent: "center",
//交叉抽
// alignItems: "center",
},
child1: {
width: 100,
height: 100,
backgroundColor: "green",
},
child2: {
width: 100,
height: 100,
backgroundColor: "blue",
}
});