js模塊的封裝


在使用一段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)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM