zoukankan      html  css  js  c++  java
  • 常见函数封装(自用,随时更新)

    1.事件绑定与事件销毁

      /*
       *说明:为了绑定事件的时候,不支持传递scope.
       *参数:绑定目标,绑定事件,绑定函数,scrop常用this
       *返回:函数(用于销毁绑定)
       */
    function connectEvent(target, event_name, fn, scope) { if (!target.on || typeof target.on != 'function') return; if (!fn || !event_name) return; const $fn = (e) => { fn.call(scope || null, e); } target.on(event_name, $fn); return $fn; } /* *说明:为了避免解绑定事件的时候,fn传递空导致解绑所有类型的事件封装 *参数:绑定目标,绑定事件,销毁上述函数 */

    function disconnectEvent(target, event_name, fn) { if (!target.un || typeof target.un != 'function') return; if (!fn || !event_name) return; target.un(event_name, fn); }
  • 相关阅读:
    参考__JAVA
    债券价格和通胀率
    C++ 面试题
    欧式和美式期权
    explicit
    smart pointer
    const pointer
    manacher-马拉车算法
    输入有空格的字符串的2种方法
    bind()与connect()——计网中socket的使用
  • 原文地址:https://www.cnblogs.com/lucio110/p/11418355.html
Copyright © 2011-2022 走看看