日期:2014-05-16 浏览次数:20433 次
var LazyLoad = Class.create({
initialize:function(elements,callback){
this.elem = elements;
this.cb = callback;
this.show();
},
show : function(){
this.cb(this.elem);
}
});
var lz = new LazyLoad('abc',function(elem){
alert(elem);
});
//对object的prototype进行extend,参数二使用Module Pattern ^_^
Object.extend(LazyLoad.prototype,(function(){
function display(){
alert(this.elem);
}
return {
display:display,
dd:display//实现别名的功能^_^
}
})());
var lz2 = new LazyLoad('cbd',function(elem){
alert(elem);
});
lz2.display();
lz2.dd();