如何在 react-native 中组合多个内联样式对象和内联 css?
How to combine multiple inline style objects and inline css in react-native?
如何在react-native中组合多个内联样式对象和内联css?
它有 3 个样式对象 TimelineGreenColor、TimelineLeftBorder、TimelineLeftLine 在视图中使用 div
const stylesB = StyleSheet.create( {
TimelineGreenColor:
{
backgroundColor: "green",
},
TimelineLeftBorder:
{
position: 'absolute',
width: 4,
backgroundColor: "green",
height: '100%',
left: 4,
top: 15,
},
TimelineLeftCircle:
{
position: 'absolute',
width: 12,
height: 12,
backgroundColor: "green",
top: 12,
borderRadius: 50,
left: 0,
/*boxShadow: "0px 0px 10px -2px black",*/
},
TimelineLeftLine:
{
position: 'absolute',
width: 15,
height: 3,
backgroundColor: "green",
top: 16,
left: 5,
}
<View style={how to write styles in react-native ??????????}></View>
类型 1:如果你有一种内联样式
<View style = {{marginLeft: 7,paddingRight: "9%"}}></View>
类型 2:如果您有来自样式对象的一种样式
<View style = {styles.TimelineLeftBorder}></View>
类型 3:如果您有两个或更多来自样式对象的样式
<View style = {[styles.TimelineLeftBorder,styles.TimelineGreenColor]}></View>
类型 4:如果您有来自样式对象的两个或多个样式,并且您想要提供普通内联 css 也
<View style = {[styles.TimelineLeftBorder,styles.TimelineGreenColor,{marginLeft: 7}]}></View>
只需将所有样式对象传递到 style prop 数组中即可。
<View style={[stylesB.TimelineGreenColor,styleB.TimelineLeftBorder,styleB.TimelineLeftCircle,styleB.TimelineLeftLine]}/>
请记住,style 道具在多种样式的情况下接受样式对象数组,在单一样式的情况下接受样式对象的对象。
如何在react-native中组合多个内联样式对象和内联css?
它有 3 个样式对象 TimelineGreenColor、TimelineLeftBorder、TimelineLeftLine 在视图中使用 div
const stylesB = StyleSheet.create( {
TimelineGreenColor:
{
backgroundColor: "green",
},
TimelineLeftBorder:
{
position: 'absolute',
width: 4,
backgroundColor: "green",
height: '100%',
left: 4,
top: 15,
},
TimelineLeftCircle:
{
position: 'absolute',
width: 12,
height: 12,
backgroundColor: "green",
top: 12,
borderRadius: 50,
left: 0,
/*boxShadow: "0px 0px 10px -2px black",*/
},
TimelineLeftLine:
{
position: 'absolute',
width: 15,
height: 3,
backgroundColor: "green",
top: 16,
left: 5,
}
<View style={how to write styles in react-native ??????????}></View>
类型 1:如果你有一种内联样式
<View style = {{marginLeft: 7,paddingRight: "9%"}}></View>
类型 2:如果您有来自样式对象的一种样式
<View style = {styles.TimelineLeftBorder}></View>
类型 3:如果您有两个或更多来自样式对象的样式
<View style = {[styles.TimelineLeftBorder,styles.TimelineGreenColor]}></View>
类型 4:如果您有来自样式对象的两个或多个样式,并且您想要提供普通内联 css 也
<View style = {[styles.TimelineLeftBorder,styles.TimelineGreenColor,{marginLeft: 7}]}></View>
只需将所有样式对象传递到 style prop 数组中即可。
<View style={[stylesB.TimelineGreenColor,styleB.TimelineLeftBorder,styleB.TimelineLeftCircle,styleB.TimelineLeftLine]}/>
请记住,style 道具在多种样式的情况下接受样式对象数组,在单一样式的情况下接受样式对象的对象。