- 【強制】 當組件使用樣式屬性達到三個或者三個以上時,必須使用StyleSheet來創建樣式屬性并進行引用;
```
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
marginTop:Common.scaleSize(10)
}
});
```
- 【推薦】 當使用單一屬性,或者全局樣式屬性時,推薦使用公共樣式類;
```
// StyleCommon.js
export default {
topColor:{
backgroundColor: '#3A3D42',
},
mainView:{
backgroundColor: '#12141B',
},
}`在這里插入代碼片`
```
- 【推薦】 當使用多個state或者props值時,推薦使用以下方式;
```
const {size, dotRadius, color} = this.props;
const { maxNumber,minNumber,}=this.state;
```
使用此方式,代碼結構清晰簡潔,便于維護;