1 Star 38 Fork 5

Yaohaixiao / delegate.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
once.js 855 Bytes
一键复制 编辑 原始数据 按行查看 历史
import on from './on'
/**
* 绑定只触发一次的事件
* ========================================================================
* @method once
* @param {HTMLElement} el - (必须)绑定代理事件的 DOM 节点
* @param {String} selector - (必须)事件代理目标 DOM 元素的选择器
* @param {String} type - (必须)事件类型
* @param {Function} fn - (必须) 事件处理器回调函数
* @param {Object} data - (可选)传递给事件处理器回调函数的数据对象
* @param {Object|Boolean} context - (可选)事件处理器回调函数的 this 上下文指向,
* 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象
*/
const once = (el, selector, type, fn, data, context) => {
on(el, selector, type, fn, data, context, true)
}
export default once
JavaScript
1
https://gitee.com/yaohaixiao/delegate.js.git
git@gitee.com:yaohaixiao/delegate.js.git
yaohaixiao
delegate.js
delegate.js
main

搜索帮助