class Epp extends Component {
constructor()
{
super();
this.fn=this.fn.bind(this);//注意这一步需在constructor()中设置
}
fn(event)
{
console.log('123')
}
render() {
return (
<div onClick={this.fn}>
123
</div>
);
}
}
class Epp extends Component {
constructor()
{
super();
}
fn(event)
{
console.log('123')
}
render() {
return (
<div onClick={this.fn.bind(this)}>
123
</div>
);
}
}
class Epp extends Component {
constructor()
{
super();
this.fn=this.fn.bind(this);
}
fn=(event)=>
{
console.log('123')
}
render() {
return (
<div onClick={this.fn}>
123
</div>
);
}
}