[TOC] ## 事件名为驼峰写法 ``` <button onClick={activateLasers}> Activate Lasers </button> ``` ## 阻止默认事件 ``` function ActionLink() { function handleClick(e) { e.preventDefault(); console.log('The link was clicked.'); } return ( <a href="#" onClick={handleClick}> Click me </a> ); } ``` ## bind 绑定this ``` constructor(props) { super(props); this.state = {isToggleOn: true}; // 为了在回调中使用 `this`,这个绑定是必不可少的 this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState(state => ({ isToggleOn: !state.isToggleOn })); } ``` ## 向事件中传递参数 两中都可以 ``` <button onClick={(e) => this.deleteRow("123", e)}>Delete Row</button> <button onClick={this.deleteRow.bind(this, "123")}>Delete Row</button> ```