import React,{Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity,
AlertIOS,
} from 'react-native';
class test1 extends Component{
state = {
title:'默认值'
}
render(){
return(
<View style={styleObj.styleView}>
{/*触发的状态*/}
<TouchableOpacity style={styleObj.styleText}
activeOpacity={1.0}
onPress={()=>this.click('点击')}
onPressIn={()=>this.click('按下')}
onPressOut={()=>this.click('抬起')}
onLongPress={()=>this.click('长按')}>
<View>
<Text> {this.state.title}</Text>
</View>
</TouchableOpacity>
</View>
);
}
//点击事件
click(event){
console.log(event);
this.setState ({
title:event
})
}
}
const styleObj = StyleSheet.create({
styleView:{
marginTop:100,
},
});
module.exports = test1;
TouchableOpacity
最新推荐文章于 2019-10-26 16:39:02 发布