2020
10-09
10-09
详解三种方式在React中解决绑定this的作用域问题并传参
在React中时常会遇到this指向的作用域问题从而导致undefined报错先来个Demo:功能很简单点击按钮改变文字importReactfrom'react';exportdefaultclassBindWithThisextendsReact.Component{constructor(props){super(props);this.state={msg:"BindWithThis"}}render(){return<div><inputtype="button"value="Way1"onClick={this.changeMsg1}/><hr/><h3>{this.sta...
继续阅读 >