jquery插件支持AMD和CMD规范的改造:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
;function(root, factory) {
"use strict";
if (typeof define === 'function' && (define.amd || define.cmd)) {

// register as anon module
define(['jquery'], factory);

} else {

// invoke directly
factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto );

}
}(this, function($){
'use strict';

// your code

});