<XXView xxxx={this.xxA.bind(this)} />
constructor(props) {
super(props);
this.xxA= this.xxA.bind(this);
}xxA = ()=>{};
<XXView xxxx={this.xxA} /><XXView xxxx={()=>this.xxA} />1和2一样,3和4一样吧。
那么实际中大家更倾向哪种写法?
求教用箭头函数和用bind,有什么区别呢?哪个更好呢?
相关分类