【发布时间】:2017-07-10 10:07:56
【问题描述】:
这是我的代码,有 2 个文件:
文件 b.js
module.exports.data = function() {
return new Date();
}
文件 a.js
var a = require("./b")
var http = require('http')
http.createServer(function(req, res) {
res.writeHead(200, {'Content-type':'text/plain'})
res.write('the date is: '+a.data)
res.end();
}).listen(8000)
为什么不打印日期?
【问题讨论】:
-
你需要使用
a.data()而不是a.data
标签: javascript node.js node.js-connect node.js-client