Javascript 是否使用绑定运算符转换函数?
既然Javascript 是否使用绑定运算符转换函数?,javascript,reactjs,ecmascript-next,Javascript,Reactjs,Ecmascript Next,既然this.handler.bind(this)可以替换为::this.handler,我如何使用::替换this.handler.bind(this,1) 我发现这在我想附加处理程序来响应组件的情况下很有用。例如: handler(x) { this.setState({counter: x}) } <a onClick={this.handler.bind(this, 5)}>increment by 5</a> 当前指定的应用程序不包含部分应用程序。只需继
this.handler.bind(this)
可以替换为::this.handler
,我如何使用::
替换this.handler.bind(this,1)
我发现这在我想附加处理程序来响应组件的情况下很有用。例如:
handler(x) {
this.setState({counter: x})
}
<a onClick={this.handler.bind(this, 5)}>increment by 5</a>
当前指定的应用程序不包含部分应用程序。只需继续使用bind
(this.handler.bind(this,5)
或一个简单的箭头函数e=>this.handler(5,e)
)
<a onClick={_.curry(::this.handler, 5)}>increment by 5</a>