generated from SystemLight/T-webpack5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b30e267
commit 379c828
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
# event-proxy | ||
|
||
> Event agent processing library. | ||
### Usage | ||
|
||
```javascript | ||
eventProxy('click', '.selector').on(function (e) { | ||
console.log('事件触发') | ||
}) | ||
|
||
eventProxy('click', '.parent', '.selector').on(function (e) { | ||
console.log('事件代理') | ||
}) | ||
|
||
eventProxy('click', '.parent', '.selector').use(function (e, next) { | ||
console.log('before middleware') | ||
next() | ||
}).on(function (e) { | ||
console.log('中间件') | ||
}).use(function (e, next) { | ||
console.log('after middleware') | ||
// 触发一次后关闭 | ||
this.off() | ||
next() | ||
}) | ||
|
||
eventProxy('click', '.parent', '.selector').one(function (e) { | ||
console.log('只触发一次事件') | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters