绑定事件。
Signature:
export declare function bindEvent<T extends Record<'addEventListener' | 'removeEventListener', AnyFunction_2>>(target: T): BindEventFunction<T>;
Parameter | Type | Description |
---|---|---|
target | T | 事件绑定的目标 |
Returns:
返回事件绑定函数
const bindWindowEvent = bindEvent(window)
const unbindClick = bindWindowEvent('click', console.log)
const unbindScroll = bindWindowEvent('scroll', console.log)