导入组件TouchableOpacity
支持 :点击、按下、松手、长按 需要在点击的组件上覆盖一层TouchableOpacity
e.g:
// ES5的写法写类var tempClass = React.createClass({ getInitialState() { return{ title:'我是一个测试' // 默认是第一个 } }, render() { return ({/* 调用方法*/} ); }, activityEvent(event) { this.setState({ title: event }); }})复制代码this.activityEvent('测试')} onPressIn={()=>this.activityEvent('测试')} onPressOut={()=>this.activityEvent('测试')} onLongPress={()=>this.activityEvent('长按')} > {this.state.title}