日期:2014-05-16  浏览次数:20360 次

封装属于自己的JS库
(function(){
if(!window.project){
window.project = {};
}
window.project = {
init:function(){
alert("test");
},
show:function(){
alert("test2");
}

};
  })();
  调用:project.init();



/////////////////////////////////////////////////////////////////////////////
function Range(){}
Range.prototype = {
init:function(){
alert("XXX");
},
show:function(){
alert("YYY");
}
};

function RangeChildren(){}
RangeChildren.prototype = Range.prototype;
RangeChildren.prototype.add = function(){
alert("ADD");
};


调用:var rc = new RangeChildren();
rc.add();
rc.show();