Carousel.init()這個初始方法 中 new _this_($this);的詳解
Carousel.init = function(Objs){
????var _this_ this ;
????Objs.each(function(){
????????new _this_(this);
????});
????}
Carousel.init = function(Objs){
????var _this_ this ;
????Objs.each(function(){
????????new _this_(this);
????});
????}
舉報(bào)
2017-01-01
var _this=this:這里的this就是對象Carousel;obj.each():jQuery中遍歷對象的方法;new Function():js中實(shí)例化類的方法,new ?_this_(this):可以理解成new Carousel($(this)); $(this)中的this指的是傳入的對象,有可能是多個;就可以實(shí)現(xiàn)下面的多個調(diào)用。
這樣可以實(shí)現(xiàn)創(chuàng)建多個對象的效果。
2016-11-17
var lightBoxs = new Carousel($(".J_Poster").eq(0)); 對應(yīng)這一句