xiao

.............

nodejs笔记

模块

  在Node环境中,一个.js文件就称之为一个模块(module)。

一个模块:

     function greet(name) {
            console.log(s + ', ' + name + '!');
     }
     module.exports = greet; //在模块中对外输出变量

使用模块:

     var greet = require('./hello');
     var s = 'Michael';
     greet(s); // Hello, Michael!
posted @ 2018-08-23 17:22  蓝色风暴003  阅读(94)  评论(0编辑  收藏  举报