CommonJS 与AMD 、CMD 的区别

CommonJS是一种规范,是一种模块化的规范。它有一个全局方法require(),用于加载模块。

var math =require('math');
  math.add(2,3);//5

     CommonJS 定义的模块分为:{模块引用(require)}{模块定义(exports)} {模块标识(module)}

     require()用来引入外部模块;exports 对象用于当前模块的方法或变量,唯一的dao'chu'kou

posted on 2017-05-11 14:41  zkBlog  阅读(75)  评论(0编辑  收藏  举报