带有无法解释的未定义方法错误的addEventListener [英] addEventListener with inexplicable undefined method error

查看:80
本文介绍了带有无法解释的未定义方法错误的addEventListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直找不到这个问题的答案.

I couldn't find an answer to this problem I've been having.

function UploadBar() {
    this.reader = new FileReader();
    this.reader.addEventListener(
        "onloadstart"
        , function(evt) {alert("Hello World");}
        , false
    );
}

当我尝试运行此代码时,它在chrome的JavaScript调试器中给了我一个undefined_method_error.有人能告诉我这是怎么回事吗?

when I try to run this code it gives me an undefined_method_error in the javascript debugger in chrome. Could anyone be so kind as to tell me what is wrong here?

推荐答案

reader不是元素,因此请不要使用.addEventListener,而是执行以下操作.

reader is not an element, so don't use .addEventListener Instead do the following.

function UploadBar() {
    this.reader = new FileReader();
    this.reader.onloadstart = function(e) { alert('Hello World') };  
}

这篇关于带有无法解释的未定义方法错误的addEventListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆