React-Native 引用样式的方式

2016-08-15  本文已影响1403人  json_jie

import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';

class hello extends Component {
  render() {
   return (
  <View style={styles.container}>
    <View style = {[styles.viewStyle,{backgroundColor:'white'},{width:100,height:150}]}>
    <Text>1  第一种样式</Text>
    </View>
    <View style = {{backgroundColor:'yellow',height:120,width:100,marginLeft:10}}>
    <Text>2 第二种样式</Text>
    </View>
    <View style = {{backgroundColor:'white',height:190,width:100,marginLeft:10}}>
    <Text>3</Text>
    </View>

    <View style = {[styles.viewStyle,{backgroundColor:'white'},{width:100,height:100}]}>
    <Text>4  第三种样式</Text>
    </View>
    <View style = {{backgroundColor:'yellow',height:120,width:100,marginLeft:10}}>
    <Text>5</Text>
    </View>
    <View style = {{backgroundColor:'white',height:190,width:100,marginLeft:10,marginTop:10}}>
    <Text>6</Text>
    </View>
    <View style = {[styles.viewStyle,styles.viewStyleCon]}>
    <Text style = {{backgroundColor:'red'}}>reactView7  第四种样式</Text>
    </View>
  </View>
);
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'red',
    flexDirection:'row',
    flexWrap:'wrap',
    alignItems:'center',
    justifyContent:'space-around',
    alignSelf:'stretch',
  },

  viewStyle:{
    backgroundColor:'green',
    height:100,
    width:100
  },
viewStyleCon:{
  alignItems:'center',
  justifyContent:'center'
},
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});
AppRegistry.registerComponent('hello', () => hello);
上一篇 下一篇

猜你喜欢

热点阅读