时间:2021-07-01 10:21:17 帮助过:4人阅读
案例:
hello.js—定义模块
[code]function Hello () { var name; this.setName = function (aName) { name = aName; }; this.getName = function () { console.log('Hi, ' + name); } } module.exports = Hello;
getHello.js—引入模块
[code]var Hello = require('./hello.js'); var hello = new Hello(); hello.setName('张三'); hello.getName();
以上就是Node.js 模块的应用的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!