Last active
August 29, 2015 14:03
-
-
Save nevergiveup-j/727ac222c6a75fc65bf5 to your computer and use it in GitHub Desktop.
AMD兼容的jQuery插件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function (factory) { | |
if (typeof define === "function" && define.amd) { | |
// AMD模式 | |
define([ "jquery" ], factory); | |
} else { | |
// 全局模式 | |
factory(jQuery); | |
} | |
}(function ($) { | |
"use strict"; | |
// 默认配置 | |
var defaults = { | |
} | |
function Plugin( element, options ) { | |
}; | |
Plugin.prototype = { | |
version: '1.0', | |
init: function() { | |
} | |
} | |
$.fn.plugin = function( options ) { | |
options = $.extend(true, {}, defaults, options); | |
return this.each(function() { | |
var $this = $(this); | |
//$this.data('plugin', new ShareApi()); | |
new Plugin( $this, options ); | |
}) | |
} | |
// ADM | |
return plugin; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment