RN components of TouchableOpacity

constructor(props){
    super(props);
    this.state = {
      title:'不透明触摸'
    }
    this.activiEvent = this.activiEvent.bind(this);
  }
  render() {
    return (

      <View>
        {/*
        onPress={this.renderPress()}
        onPress={()=>this.activiEvent('点击')}
        onPressIn={()=>this.activiEvent('按下')}
        onPressOut={()=>this.activiEvent('抬起')}
        onLongPress={()=>this.activiEvent('长按')}
        */}
        <View>
          <TouchableOpacity activeOpacity = {0.5} 
          The onPress = {() => the this .activiEvent ( 'click' )} 
          onPressIn = {() => the this .activiEvent ( 'pressed' )} 
          onPressOut = {() => the this .activiEvent ( 'lift' ) } 
          onLongPress = {() => the this .activiEvent ( 'long press' )}
           > 
            <View> 
              <the text> I used text but can click event </ the text> 
            </ View> 
          </ TouchableOpacity> 
        </ View> 

        < View> 
          <the Text> { the this .state.title} </ the Text>{/ * Use braces value * / tag within} 
        </ View>

      </ View> 
    ); 
  } 
  renderPress () { 
    { / * No clicking on the pop braces annotation function can not be written in the outer outer braces tag comment tag can be // * / } 
    Alert.alert ( 'the iOS ' ) 
  } 
  activiEvent (Event) { the this .setState ({ 
      title: Event 
    }) 
  }




    

 

Guess you like

Origin www.cnblogs.com/liuw-flexi/p/11512521.html