为了账号安全,请及时绑定邮箱和手机立即绑定

为什么封装的方法要初始化一下

为什么封装的方法要初始化一下

欧罗巴皇 2017-07-17 11:15:28
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";                        // 打开遮罩层的回调                          _this.options.open && _this.options.open();                    }, false);                    this.boxDom.addEventListener("click", function () {                        this.style.display = "none";                        // 关闭遮罩层的回调                          _this.options.close && _this.options.close();                    }, false);                }}var  bbb=new aaa(".abc",{//一波骚赋值})
查看完整描述

1 回答

?
MR帽子先生

TA贡献245条经验 获得超106个赞

以防内部文件被占用,都要进行初始化的。

希望对你有帮助,祝你学习愉快。

查看完整回答
反对 回复 2017-07-17
  • 1 回答
  • 0 关注
  • 1281 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信