开发者

Creating modules to be required in other files in Javascript?

In Node.js I can use a module like this:

开发者_开发问答
sys = require("sys");

How do I create my own module like "sys" so that I can require it from other files?


The API contains an example of writing your own module: http://nodejs.org/api.html#modules-312


You probably want to look into CommonJS http://www.commonjs.org/. Node follows this protocol for require(). Some of the documentation on CommonJS describes projects that implement this in the browser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜