-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoff.js
More file actions
24 lines (21 loc) · 863 Bytes
/
Copy pathoff.js
File metadata and controls
24 lines (21 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import purgeElement from './purgeElement'
import isFunction from './utils/isFunction'
import _off from './_off'
/**
* 取消 type 类型的代理事件绑定
* ========================================================================
* 如果没有设置 handler,则销毁 this.$options 绑定的所有符合 type 事件类型的事件绑定
* ========================================================================
* @method off
* @param {HTMLElement} el - (必须)取消事件绑定的 DOM 元素
* @param {String} type - (必须)事件类型
* @param {Function} [fn] - (可选)事件处理器回调函数
*/
const off = (el, type, fn) => {
// 如果不设置 fn 参数,默认清除 el 元素上绑定的所有事件处理器
if (!isFunction(fn)) {
return purgeElement(el, type)
}
_off(el, type, fn)
}
export default off