classAppextendsReact.Component{state={counter:0,};handleClick=()=>{constcounter=this.state.counter;this.setState({counter:counter+1});};//如果写成下面的形式,则点击无效,这两者区别是什么handleClick(){constcounter=this.state.counter;this.setState({counter:counter+1});};render(){return(counteris:{this.state.counter}点我 )}}
MMMHUHU
相关分类