Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

mitt 的 uni_modules 完美迁移版本

License

NotificationsYou must be signed in to change notification settings

markthree/tob-mitt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue3 中,mitt 是一个推荐的eventBus 库。这是一个uni_modules 的完美迁移版本。



原仓库 📦

👉mitt



Usage 🦖

importmittfrom"@/uni_modules/tob-mitt/index.js"constbus=mitt()// 注册两个指定类型的事件函数bus.on('foo',()=>console.log('我是foo1'))bus.on('foo',()=>console.log('我是foo2'))// 触发该类型的事件函数bus.emit('foo')// 将打印 我是foo1,我是foo2// 注册一个带形参的事件函数bus.on('bar',(msg)=>console.log(msg))// 触发事件函数的同时设置实参bus.emit('bar','你好')// 将打印 你好bus.off('bar')// 卸载所有 bar 事件函数constbar=()=>console.log('我好')bus.on('bar',bar)bus.off('bar',bar)// 单独卸载该事件函数bus.emit('bar')// 因为被卸载了,所以什么都不会触发// 注册所有类型的事件函数bus.on('*',()=>{console.log("不论什么时候都会触发")})// 触发 * 类型的事件函数bus.emit()// 打印 不论什么时候都会触发bus.emit('foo')// 打印 我是foo1,我是foo2 不论什么时候都会触发bus.all// 保存事件函数的 map


组织 🦔

欢迎关注帝莎编程



License

Made with markthree

Published underMIT License.

About

mitt 的 uni_modules 完美迁移版本

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp