慕丝4181516
2020-08-15 21:18
(function ($) { var Carousel = function (obj) { this.poster = obj; // 默认配置 this.setting = { width: 1000, height: 270, posterWidth: 640, posterHeight: 270, scale: 0.9, verticalAlign: "middle", speed: 500, }; console.log(this.getSetting()); }; Carousel.prototype = { // 获取人工配置参数 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);
在getsetting方法中return this.setting是可以的,但只要改成return $.parseJSON(setting)就报错
属性的双引号加上了 但问题仍未解决
JS实现“旋转木马”幻灯片效果
66442 学习 · 147 问题
相似问题