React 事件绑定方式
1.bind 绑定方法
这个方法可以帮助我们绑定事件处理器内的this,并可以向事件处理器中传递参数。
import React from 'react';
class App extends React.Component {
handleClick(e) {
console.log(e)
}
render () {
return <button onClick={this.handleClick.bind(this,'test')}>Test</button>
}
原创
2020-09-22 21:53:57 ·
139 阅读 ·
0 评论