feat: Add example-page demo

This commit is contained in:
kailong321200875
2022-02-19 14:26:05 +08:00
parent 262f4211cf
commit 1492f9119a
14 changed files with 639 additions and 36 deletions

23
src/hooks/web/useEmitt.ts Normal file
View File

@@ -0,0 +1,23 @@
import mitt from 'mitt'
import { onBeforeUnmount } from 'vue'
interface Option {
name: string // 事件名称
callback: Fn // 回调
}
const emitter = mitt()
export const useEmitt = (option?: Option) => {
if (option) {
emitter.on(option.name, option.callback)
onBeforeUnmount(() => {
emitter.off(option.name)
})
}
return {
emitter
}
}