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)

posted @ 2018-10-01 13:03  scd  阅读(1402)  评论(0编辑  收藏  举报