Skip to content

Commit 82693af

Browse files
docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ 5bc25d3 (#1172)
2 parents 60ce16e + 484bfce commit 82693af

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/content/learn/responding-to-events.md

+6
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ button { margin-right: 10px; }
318318

319319
请注意,`App` 组件并不需要知道 `Toolbar` 将会对 `onPlayMovie``onUploadImage`**什么** 。上述示例是 `Toolbar` 的实现细节。其中,`Toolbar` 将它们作为 `onClick` 处理函数传递给了 `Button` 组件,其实还可以通过键盘快捷键来触发它们。根据应用程序特定的交互方式(如 `onPlayMovie`)来命名 prop ,可以让你灵活地更改以后使用它们的方式。
320320

321+
<Note>
322+
323+
Make sure that you use the appropriate HTML tags for your event handlers. For example, to handle clicks, use [`<button onClick={handleClick}>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) instead of `<div onClick={handleClick}>`. Using a real browser `<button>` enables built-in browser behaviors like keyboard navigation. If you don't like the default browser styling of a button and want to make it look more like a link or a different UI element, you can achieve it with CSS. [Learn more about writing accessible markup.](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML)
324+
325+
</Note>
326+
321327
## 事件传播 {/*event-propagation*/}
322328

323329
事件处理函数还将捕获任何来自子组件的事件。通常,我们会说事件会沿着树向上“冒泡”或“传播”:它从事件发生的地方开始,然后沿着树向上传播。

0 commit comments

Comments
 (0)