addEventListener
Регистрирует обработчик события в глобальной области видимости, который будет вызываться синхронно всякий раз, когда событие type отправляется.
addEventListener('unload', () => { console.log('All finished!'); });
...
dispatchEvent(new Event('unload'));
function addEventListener<K extends keyof WindowEventMap>(type: K,listener: (this: Window, ev: WindowEventMap[K]) => any,options?: boolean | AddEventListenerOptions,): void;function addEventListener(type: string,listener: EventListenerOrEventListenerObject,options?: boolean | AddEventListenerOptions,): void;
addEventListener<K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void
Регистрирует обработчик события в глобальной области видимости, который будет вызываться синхронно всякий раз, когда событие type отправляется.
addEventListener('unload', () => { console.log('All finished!'); });
...
dispatchEvent(new Event('unload'));
Типы параметров
K extends keyof WindowEventMapПараметры
type: Klistener: (this: Window, ev: WindowEventMap[K]) => anyoptions?: boolean | AddEventListenerOptions optionalТип возвращаемого значения
voidaddEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void
Параметры
type: stringlistener: EventListenerOrEventListenerObjectoptions?: boolean | AddEventListenerOptions optionalТип возвращаемого значения
void
© 2018–2022 the Deno authors
https://doc.deno.land/deno/stable/~/addEventListener