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

class Goodmoring extends Component{  //定制化组件
  static defaultProps={
    name:"somebody",
  };
  
  render(){
    return (
    <View >
        <Text style={styles.welcome} >
        Good morning,Wang!{this.props.name}
        </Text>
    </View>
    )
  }
  
}


class App extends Component {  
  render() {
 
    return (
   //定制化组件使用
      <View style={styles.container}>
          <Goodmoring style={styles.welcome} name="哒哒"  />
        <Text style={styles.welcome}>
        wanghuanlong
        </Text>  
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 5,
    textAlign: 'center',
    margin: 10,
  },
})

AppRegistry.registerComponent('App', () => App)

 

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐