Skip to content

Instantly share code, notes, and snippets.

@nevergiveup-j
Last active August 29, 2015 14:03
Show Gist options
  • Save nevergiveup-j/727ac222c6a75fc65bf5 to your computer and use it in GitHub Desktop.
Save nevergiveup-j/727ac222c6a75fc65bf5 to your computer and use it in GitHub Desktop.
AMD兼容的jQuery插件
;(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