x***@sina.cn
x***@sina.cn
  • 发布:2020-09-12 11:52
  • 更新:2020-09-12 11:52
  • 阅读:485

【报Bug】内置js的 removeEventListener的写法是错误的

分类:HTML5+

产品分类: HTML5+

HBuilderX版本号: 2.8.11

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: 任意

打包方式: 云端

操作步骤:

-

预期结果:

-

实际结果:

-

bug描述:

以webview的为例, 内置的如下

e.prototype.removeEventListener = function(e, t) {  
                var n = !1;  
                return this.__callbacks__[e] && (this.__callbacks__[e].**pop(t)**,  
                (n = 0 === this.__callbacks__[e].length) && (this.__callbacks__[e] = null)),  
                n  
            }

可用的参考代码

/**  
* @param evt string  
* @param method function  
* @return boolean  
*/  
e.prototype.removeEventListener = function(evt, method) {  
    var evts = this.__callbacks__[evt]  
    if (evts) {  
        var _cbIndex = evts.indexOf(method)  
        if (_cbIndex > -1) {  
            evts.splice(_cbIndex, 1)  
            if (evts.length === 0) {  
                delete this.__callbacks__[evt]  
            }  
            return true  
        }  
        return false  
    }  
    return false  
}
2020-09-12 11:52 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复