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