UNPKG

bootstrap-vue-3

Version:

Early (but lovely) implementation of Vue 3, Bootstrap 5 and Typescript

18 lines (14 loc) 377 B
import {onBeforeUnmount, onMounted, Ref} from 'vue' function useEventListener( element: Ref<HTMLElement | undefined>, event: string, callback: EventListener ): void { onMounted(() => { element?.value?.addEventListener(event, callback) }) onBeforeUnmount(() => { element?.value?.removeEventListener(event, callback) }) } export default useEventListener