项目中用到了一些js库,发现他们的头部都适配了amd和cmd模块化开发,现如下列表:
/*loadingmodal.js*/
!function(t, i) {
"function" == typeof define && define.amd ? define(["jquery"], i) :
"object" == typeof exports ? module.exports = i() :
t.loadingmodal = i(window.Zepto || window.jQuery || $)
} (this, function (t) {})
/*messages_zh.js*/
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
define( ["jquery", "validate"], factory );
} else {
factory( jQuery );
}
}(function( $ ) {}))
/*vue-datepicker-local.js*/
!function (e, t) {
"object" == typeof exports && "object" == typeof module ? module.exports = t() :
"function" == typeof define && define.amd ? define(["vue"], t) :
"object" == typeof exports ? exports["vue-datepicker-local"] = t() :
e["vue-datepicker-local"] = t()
}("undefined" != typeof self ? self : this, function (Vue) {})
/*vue-router.js*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.VueRouter = factory());
}(this, (function () { 'use strict';})))
/*vue-2.0.js*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Vue = factory());
}(this, (function () { 'use strict';})))
/*datatables*/
(/** @lends <global> */function( window, document, undefined ) {
(function( factory ) {
"use strict";
if ( typeof define === 'function' && define.amd ) {
// Define as an AMD module if possible
define( 'datatables', ['jquery'], factory );
}
else if ( typeof exports === 'object' ) {
// Node/CommonJS
factory( require( 'jquery' ) );
}
else if ( jQuery && !jQuery.fn.dataTable ) {
// Define using browser globals otherwise
// Prevent multiple instantiations if the script is loaded twice
factory( jQuery );
}
}
(/** @lends <global> */function( $ ) {
"use strict";
}))})
项目中自己封装js库的时候可以随意用其中一个的写法,都是一样的,大同小异。