import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native';
const styles = StyleSheet.create({ bigblue: { color: 'blue', fontWeight: 'bold', fontSize: 30 }, tinyred: { color: 'red', fontSize: 14 }});//然后在组件的props的style属性里使用 styles class LotsOfStyles extends Component { render() { return ( <View> <Text style={styles.tinyred}>just red</Text> <Text style={styles.bigblue}>just bigblue</Text> <Text style={[styles.bigblue, styles.red]}>bigblue, then red</Text> <Text style={[styles.tinyred, styles.bigblue]}>red, then bigblue</Text> </View> ); }}//如果使用数组来设置样式,后者的优先级比前者高