Skip to content

Commit

Permalink
docs: 更新 taro events 文章
Browse files Browse the repository at this point in the history
  • Loading branch information
ruochuan12 committed Aug 22, 2024
1 parent d8e9791 commit 3786af5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/taro/events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ Taro.eventCenter.off

## 3. 根据文档使用实现 Events

文档中,有如下几个需求
文档中,主要有如下几个需求点

- 监听同个事件,同时绑定多个 handler
- 触发事件,传入多个参数
- 取消监听一个事件某个 handler
- 取消监听所有事件

我们可以先自行实现一个符合要求的 `Events` 类,然后再去 `Taro` 源码中寻找实现,最后可以对比各自的实现优缺点。

### 3.1 初步实现 Events

```js
Expand All @@ -102,7 +104,7 @@ class Events {
this.callbacks = [];
}
on(eventName, callback){
this.push({
this.callbacks.push({
eventName,
callback,
});
Expand Down

0 comments on commit 3786af5

Please sign in to comment.