(function( $, window ) {
$.fn.slideInterval = function( options ) {
return this.each(function() {
$(this).css({overflow: "hidden"})
var slider = {
self: this,
init:function( options, elem ) {
self.elem = elem;
self.$elem = $( elem );
slider.action()
},
action:function() {
slider.moved.call(slider.self)
},
moved:function() {
console.log(options.fade) // options.fade is undefined
}
}
slider.init( options, this );
});
};
$.fn.slideInterval.options = function() {
var options = $.extend({
fade: 5,
ImgSlide: null,
interval: null,
bullet: 'default',
context: 'Your Title'
})( options );
};
})( jQuery, window);
我有一些问题,当我在slider方法中调用options.fade但不起作用。如何在滑块对象方法中获取选项对象属性..... ??
............................................... .................................................. .................................................. ......
答案 0 :(得分:0)
我认为您希望在调用options
时扩展传递的slideInterval
对象,但我不确定,因为您没有正确解释您的代码和问题:
(function ($, window) {
$.fn.slideInterval = function(options) {
// argument default options with passed options
options = $.extend({}, $.fn.slideInterval.options, options);
return this.each(function () {
// ...
});
};
$.fn.slideInterval.options = {
fade: 5,
ImgSlide: null,
interval: null,
bullet: 'default',
context: 'Your Title'
};
})(jQuery, window);