Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否使用绑定运算符转换函数?_Javascript_Reactjs_Ecmascript Next - Fatal编程技术网

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>