React-Native 引用樣式的方式

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);
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 在html中所有的布局都依賴于css樣式中的style繼承(css中確切來說應(yīng)該是不存在繼承關(guān)系的,而是通過樣式名...
    極光火狐貍閱讀 1,750評(píng)論 0 4
  • 為什么使用react native? 既擁有Native的用戶體驗(yàn)、又保留React的開發(fā)效率?!訰eact...
    阿波羅程序猿閱讀 901評(píng)論 0 4
  • ReactNative 基礎(chǔ) Props大多數(shù)component 都可以在創(chuàng)建時(shí)使用不同的參數(shù)進(jìn)行自定義配置,這些...
    Swart閱讀 350評(píng)論 0 0
  • React Native優(yōu)秀博客,以及優(yōu)秀的Github庫(kù)列表(很多英文資料源自于[awesome-react-n...
    董董董董董董董董董大笨蛋閱讀 11,019評(píng)論 4 162
  • 參加讀吧活動(dòng),今天的內(nèi)容是《出師表》。大家從題目表延伸到了“書、章、表、奏、議、疏”等給天子發(fā)送報(bào)告的不同形式。又...
    紅日初升江蘇閱讀 2,075評(píng)論 0 0

友情鏈接更多精彩內(nèi)容