React 组件优化
属性传递
Example
import React from 'react'
class App extends React.Component{
constructor(props){
super(props)
this.state = {
num:1
}
}
handleClick(){
this.setState({
num:this.state.num+1
})
}
render(){
return(
<div>
<h2>App</h2>
<button onClick={this.handleClick.bind(this)}>b1</button>
<button onClick={()=>this.handleClick()}>b2</button>
</div>
)
}
}
export default App;组件数据传递
最后更新于