首页 > 代码库 > 组件的写成

组件的写成

看人家老的,两种我分不太清楚:

 

似乎fancybox满足我的要求?感觉还不错的样子!!!!!!,但是这里面的参数是干什么的?

(function (window, document, $, undefined) {    //todo}(window, document, jQuery));

 

 

还有这样写的,为啥呢?有啥区别?

WebcamToy.Audio = (function (c) {}(WebcamToy));

 

 

哈根达斯camera

WebcamToy.Camera = (function () {})()

 

lottery.js

window.homeNav = {    open:function(){        //开始动画        console.log("open");    };    close:function(){        //结束动画    };}

 

定时器 ↓

var WebcamToy = {};WebcamToy.RuntimeTimer=function(){    var _this=this,endtime=180,current=0,timer;    this.update=function(){        current=0;    }    this.destroy=function(){        clearInterval(timer);        window.location.reload();    }    this.start=function(){        timer=setInterval(function(){            current++;            if(current>=endtime){                _this.destroy();            }        },1000);    }    var _init=function(){        this.start();    }    _init.apply(this,arguments);}