如果我有一个想在onClick
中使用的函数,如下所示
*使用ReactJS和语义UI
<Table.HeaderCell
onClick={this.handleSort(items)}
>
其中函数返回函数的引用,如下所示
handleSort = (items) => () => {
console.log('now')
}
那么,如何在onClick事件之外执行此函数呢?不起作用的是:
componentDidMount() {
this.handleSort.call(items);
this.handleSort(items);
}
https://stackoverflow.com/questions/52636287
复制相似问题