listen:function(){
var i,j;
var that=this;
for(i in this.event){
for(j in this.event[i]){
$(j).on(i,function(){
that[that.event[i][j]]();
});
}
}
}
在原型里绑定事件,结果只绑定了最后一个事件,是由于闭包还是什么原因
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这是因为当函数执行完后,所有$(j).on函数里的i,j值都一样了