### 对于React中函数写法,看到了有这样的写法:update = () => { ... } ,有点奇怪。
在React中函数写法:
标准函数:
update() {
this.setState({ val: this.state.val + 1 })
}
调用:
render() {
console.log('render');
return <button onClick={this.update.bind(this)}>
{this.state.val * this.state.m}
</button>
}
也可以这样:
constructor() {
super();
this.update = this.update.bind(this)
}
render() {
console.log('render');
return <button onClick={this.update}>
{this.state.val * this.state.m}
</button>
}
箭头函数:
update = () &#