搞清楚 umd
amd
commonjs
es6
的规范。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| ((root, factory) => { if (typeof define === 'function' && define.amd) { //AMD define(['jquery'], factory); } else if (typeof exports === 'object') { //CommonJS var $ = requie('jquery'); module.exports = factory($); } else { root.testModule = factory(root.jQuery); } })(this, ($) => { //todo });
|