Skip to content

Commit 2661495

Browse files
committed
2020.11.22
1 parent 3b8ac2a commit 2661495

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

Cute-React/React-Docs-Learning/React合成事件SyntheticEvent.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ const clickElement = <a href="https://www.pingan8787.com" onClick={handleClick}>
132132

133133
| | 原生事件 | React 事件 |
134134
| --- | :---: | :---: |
135-
| 事件名称命名方式 | 名称全部小写
136-
(onclick, onblur) | 名称采用小驼峰
137-
|
135+
| 事件名称命名方式 | 名称全部小写<br/>(onclick, onblur)| 名称采用小驼峰<br/>(onClick, onBlur)|
138136
| 事件处理函数语法 | 字符串 | 函数 |
139137
| 阻止默认行为方式 | 事件返回 `false` | 使用 `e.preventDefault()` 方法 |
140138

@@ -248,7 +246,7 @@ export default App;
248246

249247
```
250248
251-
可以看到输出:
249+
可以看到输出:
252250
![Synthetic-Event-React16.png](https://images.pingan8787.com/React/Synthetic-Event/Synthetic-Event-React16.png)
253251
254252
在 React 16 及之前的版本,合成事件对象的事件处理函数全部被调用之后,所有属性都会被置为 `null` 。这时,如果我们需要在事件处理函数运行之后获取事件对象的属性,可以使用 React 提供的 `e.persist()` 方法,保留所有属性:

0 commit comments

Comments
 (0)