ReactNative→事件

// ES5的写法

var  helloworld = React.createClass({
});

// ES6的写法

export default class helloworld extends Component {
});

生命周期:
三个阶段:初始化、存在、销毁
注意:default和init函数内的变量存取方法,ref的运用类似OC tag


var  helloworld = React.createClass({

  // 这个函数存放常亮
      getDefaultProps(){
        return{
          a:'常亮'
        }
      },
  // 这个函数存放变量
      getInitialState(){
        return{
          title: '默认'
        };
      },

  render() {

    return (

        
          this.actvitEvent('点击')}
              onPressIn={()=>this.actvitEvent('按下')}
              onPressOut={()=>this.actvitEvent('抬起')}
              onLongPress={()=>this.actvitEvent('长按')}
          >
            
            {this.state.title}
             {this.props.a}
             'ref测试'

             
          

        
    );
  },
      actvitEvent:function(event) {

  this.setState({
    title:event
    this.refs.tags.....
  });
  }
}
);

你可能感兴趣的:(ReactNative→事件)