在使用一段javascript后,我們需要總結經常使用的代碼,使其能夠復用,提供我們的工作效率,下面介紹幾種我自己使用的js封裝方法
var TestClass = function(){
this.init.apply(this,arguments);
}
TestClass.prototype = function(){
//屬性
//方法
init:funciton(arguments){
},
func1:function(){
},
}
使用自執行函數
!(function(w){
var testClass= w.testF = new Function(options){
}
testClass.prototype.testF1 = function(options){
}
testClass.prototype.testF2 = function(options){
}
})(window)