美文网首页
ReactNative→引用类和函数

ReactNative→引用类和函数

作者: 动感超人丶 | 来源:发表于2017-04-24 12:01 被阅读108次
    
    class GoodMorning extends Component{
    
        static defaultProps = {
            name: 'man'
        };
    
        render(){
           return(
    
                 <View>
                     <Text>{this.props.name}</Text>
                 </View>
           )
        }
    
    }
    
    const GoodEvening = (props) => {
    
        return(
    
            <Text>{props.name}</Text>
        )
    }
    
    var  helloworld = React.createClass({
    
      render() {
    
        return (
    
            <View style={styles.container}>
    
    
                <GoodMorning name="haha" />
                <GoodEvening name="lala" />
    
    
            </View>
        );
    })
    

    组件是一个class或者一个函数,class用defaultProps来访问

    相关文章

      网友评论

          本文标题:ReactNative→引用类和函数

          本文链接:https://www.haomeiwen.com/subject/zbzuzttx.html