事件绑定
class EventApp extends Component {
render(){return(<button onClick={this._clickMe.bind(this)}>点击我</button></div>) ; }
_clickMe(){
alert("组件绑定事件实现方法") ;
}
}
class EventApp extends Component {
constructor(props) {
super(props);
}
render() { return ( <button onClick = {(e) => this._clickMe(e, "使用箭头函数绑定") } > 使用箭头函数绑定事件 < /button>); }
_clickMe(e, args) {
alert("箭头函数绑定事件实现方法");
alert(args);
alert(e);
}
}
constructor(props){
super(props) ;
this.方法 = this.方法.bind(this,'event','args') ;
}
<Component 事件={this.方法}></Component>
class EventApp extends Component {
constructor(props) {
super(props);
this._clickMe = this._clickMe.bind(this);
}
render() {
return (<button onClick = { this._clickMe } > 点击我 < /button>);
}
_clickMe() {
alert("构造方法绑定事件实现方法");
}
}