var aaa=function(tagetDom,option){//各種騷代碼this.init();//此處就是初始化}aaa.prototype={init:funtion(){this.event();},event: function () { ? ? ? ? ? ? ? ? ? ?var _this = this; ? ? ? ? ? ? ? ? ? ?this.targetDom.addEventListener("click", function () { ? ? ? ? ? ? ? ? ? ? ? ?document.body.appendChild(_this.boxDom); ? ? ? ? ? ? ? ? ? ? ? ?_this.boxDom.style.display = "block"; ? ? ? ? ? ? ? ? ? ? ? ?// 打開遮罩層的回調(diào) ? ? ? ? ? ? ? ? ? ? ? ? ?_this.options.open && _this.options.open(); ? ? ? ? ? ? ? ? ? ?}, false); ? ? ? ? ? ? ? ? ? ?this.boxDom.addEventListener("click", function () { ? ? ? ? ? ? ? ? ? ? ? ?this.style.display = "none"; ? ? ? ? ? ? ? ? ? ? ? ?// 關(guān)閉遮罩層的回調(diào) ? ? ? ? ? ? ? ? ? ? ? ? ?_this.options.close && _this.options.close(); ? ? ? ? ? ? ? ? ? ?}, false); ? ? ? ? ? ? ? ?}}var ?bbb=new aaa(".abc",{//一波騷賦值})
為什么封裝的方法要初始化一下
歐羅巴皇
2017-07-17 11:15:28