是版本的问题吗?
React js 箭头函数报错
montlsC
#2
我以前也遇到这个问题,没怎么管,今天特地去 stackoverflow 查了查。
这个语法是 ES7 的,要在 babel 里设置一下才能用。
具体参考这个 stackoverflow 就好
1 Like
OshotOkill
#6
需要绑定下 this
, 在构造函数里 this.handleChange = this.handleChang.bind(this)
或者在组件上 <App onChange={ value => this.handleChange } />
, 不过后者每次都要重新渲染。
zhaoqize
#8
constructor(props) {
super(props);
…
this.handleChange = this.handleChange.bind(this);
…
}