(
问渠那得清如许,为有源头活水来。
双手奉上RN官网)
style属性用于设置样式.写法类似于web上的CSS(层叠样式表:Cascading Style Sheets).
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
class LotsOfStyles extends Component {
render() {
return (
//指定单个样式
just red
just bigblue
//指定一组样式,对于相同的部分,以最后的为准
bigblue, then red
red, then bigblue
);
}
}
//定义样式列表
const styles = StyleSheet.create({
bigblue: {
color: 'blue',
fontWeight: 'bold',
fontSize: 30,
},
red: {
color: 'red',
},
});
AppRegistry.registerComponent('LotsOfStyles', () => LotsOfStyles);