没有样式继承的 每一个组件都要单独设置样式
合并多个样式对象 同样的设置 右边的优先级更高
import React, { Component } from 'react'
import { Text, StyleSheet, View } from 'react-native'
export default class App extends Component
{
render ()
{
return (
<View style={styles.container}>
{/* 没有样式继承的 每一个组件都要单独设置样式 */}
<View style={[styles.text, { color: '#fff' }]}>
<Text style={styles.text}>羽神你就出来吧 </Text>
</View>
{/* 直接设置样式对象 */}
<View style={styles.card} />
{/* 创建样式对象 */}
<View style={{ marginTop: 8, marginBottom: 8, height: 100, backgroundColor: 'yellow' }} />
{/* 合并多个样式对象 同样的设置 右边的优先级更高 */}
<View style={[styles.card, { backgroundColor: 'blue' }]} />
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 8,
backgroundColor: '#eeeeee'
},
text: {
color: 'pink'
},
card: {
height: 100,
backgroundColor: '#fff'
}
})