首页 > 为什么_self会报错?

为什么_self会报错?

function Carousel(){
        this.prevbtn=$('#prevbtn');
        var _self=this;

        this.prevbtn.click(function(){
            _self.piclist.animate({
                alert(_self);   //error 
            })
        })
    }
    var z=new Carousel();

已经加载了JQ,这里的_self为什么会报错呢?


()=>{ alert(_self);  }

_self.piclist.animate({
                alert(_self);   //error 
            })

animate里面要么是参数obj,要么是回调函数吧,你写的这个是什么

【热门文章】
【热门文章】