【发布时间】:2013-07-15 17:49:00
【问题描述】:
如何使用 Node 的 require() 函数访问您“包含”的脚本之一中的函数?
--main-js.js--
var webnotis = require('./modules/web-notification.js')
--web-notification.js--
function getURL(host, path) {
...
}
另外,我将如何在其他必需的脚本中使用此功能?
--report-tables.js--
var cltvOut;
exports.cltv = function cltv(getURL)
{
clearTimeout(cltvOut);
cltvOut = setTimeout(function(){
if(exports.getURL('192.168.0.15', '/IMS4/Reports/calculateCLTV'))
{
cltv();
} else {
console.log('CLTV error.')
}
}, 2000);
}
webnotis2 = require('./web-notification.js')
var cltvOut;
exports.cltv = function cltv()
{
clearTimeout(cltvOut);
cltvOut = setTimeout(function(){
if(webnotis2.getUrl('192.168.0.15', '/IMS4/Reports/calculateCLTV'))
{
cltv();
} else {
console.log('CLTV error.')
}
}, 2000);
}
【问题讨论】:
标签: javascript node.js function require