NodeJS学习笔记—2.AMD规范
2016-05-20 11:45
501 查看
CommonJS加载模块是同步的,而AMD模块加在是非同步的,允许指定回调函数。由于Nodejs主要用于服务器编程,模块文件一般都存在于本地,所以加载很快,不需要考虑非同步加载,用CommonJS即可。但浏览器端是从服务器加载模块,这就需要用非同步模式,顾选择AMD会合适些。
AMD使用define方法来定义模块,如:
AMD是允许输出的模块兼容CommonJS的,所以写法可以改为:
AMD使用define方法来定义模块,如:
define(['./B'],function(){ var a=function(){ }; return{ A:a }; })
AMD是允许输出的模块兼容CommonJS的,所以写法可以改为:
define(funciton(require,exports,module){ var a=require('./B'); exports.C=function(){ } })
相关文章推荐
- NodeJS学习笔记—1.CommonJS规范
- LeetCode 25. Reverse Nodes in k-Group(反转链表)
- 在WebStorm中调试NodeJS代码
- NodeJS Express 中创建html5的server-sent event服务端
- Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
- Node安装文档
- NodeJS学习——events
- NodeJS学习笔记 - Express4.x路由操作
- LeetCode-237.Delete Node in a Linked List
- nodejs最新教程
- leetcode-24-Swap Nodes in Pairs
- nodejs学习心得
- NodeJS学习笔记
- nodejs Controller层 封装
- nodejs npm
- nodejs中module.exports和exports.xx的区别
- node socket onmessage
- Hadoop 2.0 Yarn代码:NodeManager端代码分析_NM端各服务模块的启动
- 在windows环境下基于sublime text3的node.js开发环境搭建(转)
- Failed to obtain address information for hostname mynode1: Name or service not known