jQuery插件;Can';不行

jQuery插件;Can';不行,jquery,plugins,default,options,Jquery,Plugins,Default,Options,如何使此插件代码接受默认选项 // Utility if ( typeof Object.create !== 'function' ) { object.create = function( obj ) { function F(){}; F.prototype = obj; return new F(); }; } (function( $, window, document, undefined ) { var Super = { init: functi

如何使此插件代码接受默认选项

// Utility
if ( typeof Object.create !== 'function' ) {
object.create = function( obj ) {
    function F(){};
    F.prototype = obj;
    return new F();
};
}

(function( $, window, document, undefined ) {
var Super = {
    init: function( options, elem ) {
        var self = this;

        self.elem = elem;
        self.$elem = $( elem );

        //self.alertbox( options.alertmsg );    
        self.loadingBar( options.duration );

        if ( typeof options === 'string' ) {
            self.search = options;
        } else {
            // object was passed
            self.search = options.search;
        }


        self.options = $.extend({}, $.fn.superHero.options, options );


    },

    alertbox: function( message ) {
        var self = this;

        alert(message);

    },

    loadingBar: function( duration ) {
        var self = this;

        $('#loadingBar').animate({
            width:  699             
        }, duration);



    },


};

$.fn.superHero = function( options ){
    return this.each(function() {

        var hero = Object.create( Super );
        hero.init( options, this );

        $.data( this, 'superHero', hero);

    });

};

$.fn.superHero.options = {
    alertmsg:   'Hello World!',
    duration:   8000,
};

})( jQuery, window, document );
只有在调用插件时在索引页中定义这些选项时,这些选项才起作用


如何使选项具有由用户覆盖的默认值,而不是用户要求的默认值?

事实证明,我需要调用

self.loadingBar( self.options.duration ); 
相对于

self.loadingBar( options.duration ); 

不知道有什么区别;我只知道它能用。

结果我需要打电话;self.loadingBar(self.options.duration);与自加载条(options.duration)相反;不知道有什么区别;我只知道它是有效的。