We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我们经常使用React可以发现组件内部方法调用this时候 一般都不会是组件实例 我们可以发现this可用一般在componentDidMount与render内可用 别的组件方法常常不可用this 这与js的机制有关系
总结我们稳固this的方法
React.createClass
this的bind统一放在constructor中bind constructor(){ this.xxx = this.xxx.bind(this) } //实例时候绑定this
定义方法使用箭头函数 xxx = ()=>{}
render调用处bind onClick = {this.xxx.bind(xxx)}
render调用处使用箭头绑定 this onClick = {(e)=>{this.xxx(e)}}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
我们经常使用React可以发现组件内部方法调用this时候 一般都不会是组件实例
我们可以发现this可用一般在componentDidMount与render内可用
别的组件方法常常不可用this
这与js的机制有关系
总结我们稳固this的方法
The text was updated successfully, but these errors were encountered: