在使用某js插件时,发现用法当中有这样一句
var Excel = require('exceljs');
require的用法以前没用接触过,发现并不能直接使用,于是找到如下
CommonJS
最初的commonJS的创建者想要设计一种并不局限于浏览器使用JS的
module format
……
所以建立了CommonJS规范,也就是CommonAPI。
这样做是为了分开写js还能引入使用,如上面赋值给Excel
。
requireJS
How to get started with requireJS
http://requirejs.org/docs/start.html
How to use requireJS with jQuery
http://requirejs.org/docs/jquery.html
Why AMD?(注意,此AMD非彼AMD)
http://requirejs.org/docs/whyamd.html
各个版本的jQuery官方下载:
https://code.jquery.com/( uncompressed是未压缩的,minified是min版本的)
三者之间关系:
http://stackoverflow.com/questions/16521471/relation-between-commonjs-amd-and-requirejs
AMD
Asynchronous Module Definition(AMD,异步模块定义),下面这里也讲了AMD和commonJS的关系:
https://github.com/amdjs/amdjs-api/blob/master/AMD.md