js的构造函数中 var vc_this = this;有什么用?求大神指点。谢谢!

2025-06-29 13:27:09
推荐回答(2个)
回答1:

给你一个例子,你就知道了。

function VideoControl(){
    var self = this;
    document.getElementById('xx').onload = function(){
        alert(this.id + "," + self.id);
    }     
}

回答2:

将当前的执行环境变量,传递给vc_this