执行this.setSettingValue()时出错
报错:carousel.js:34 Uncaught SyntaxError: Unexpected identifier
index.html:41 Uncaught ReferenceError: Carousel is not defined
代码:
;(function($){
var Carousel=function(poster){
//保存单个旋转木马对象
this.poster=poster;
//默认配置参数
this.setting={
"width":1000, //幻灯片的宽度
"height":270, //幻灯片的高度
"posterWidth":640, //幻灯片第一帧的宽度
"posterHeight":270, //幻灯片第一帧的高度
"scale":0.9,
"speed":500,
"verticalAlign":"middle"
};
$.extend(this.setting,this.getSetting());
//设置配置参数值
this.setSettingValue();
}
Carousel.prototype={
//设置配置参数值去控制基本的宽度高度。。。
setSettingValue:function(){
this.poster.css({
width:this.setting.width,
height:this.setting.height
});
}
//获取人工配置参数
getSetting:function(){
var setting=this.poster.attr("data-setting");
if(setting&&setting!=""){
return $.parseJSON(setting);
}else{
return {};
};
}
};
Carousel.init=function(posters){
var _this_=this;
posters.each(function(){
new _this_($(this));
});
};
window["Carousel"]=Carousel;
})(jQuery);