fix: vue ssr (#867)

closes #840
This commit is contained in:
Georges KABBOUCHI
2021-10-20 19:23:41 +03:00
committed by GitHub
parent fd9a2d20b2
commit 9f638c9eb7
@@ -5,6 +5,8 @@ export function useWindowEvent<TType extends keyof WindowEventMap>(
listener: (this: Window, ev: WindowEventMap[TType]) => any,
options?: boolean | AddEventListenerOptions
) {
if (typeof window === 'undefined') return
watchEffect(onInvalidate => {
window.addEventListener(type, listener, options)