-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
react向组件传递函数方式
bind
constructor(props) {
super(props);
this.state = {
value: 0
};
this.handleClick2 = this.handleClick1.bind(this);
}箭头函数
handleClick3 = () => {
console.log(this);
};直接传递
handleClick1() {
console.log(this);
}<button onClick={this.handleClick1}>click 1</button>
<button onClick={this.handleClick2}>click 2</button>
<button onClick={this.handleClick3}>click 3</button>