Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery插件样板_Jquery - Fatal编程技术网

jQuery插件样板

jQuery插件样板,jquery,Jquery,我想知道你们怎么看待这个样板 ;(function( $, window, document, undefined ) { // plugin's name $.fn.plugin = function(method, options) { // defaults var defaults = { property: "value" }; // overwrites default optio

我想知道你们怎么看待这个样板

;(function( $, window, document, undefined ) {
    // plugin's name
    $.fn.plugin = function(method, options) {
        // defaults
        var defaults = {
            property: "value"
        };
        // overwrites default options
        var settings = $.extend( {}, defaults, method, options );
        // methods object
        var methods = {
            // method's namespace 
            methodA: function() {
                // code goes here
            }
        };
        // return a valid method
        if ( methods[method] ) {
            return methods[method].apply( this );
        } else if ( typeof method === "object" ) {
            return methods.fade.apply( this );
        } else {
            console.error( "Method %d does not exist in jQuery.transition", method );
        }       
    };  
})( jQuery, window, document );
它似乎工作得很好,但我不太确定它的性能和良好的实践,尽管它非常类似于jquery的社交创作