【发布时间】:2016-09-13 11:02:01
【问题描述】:
以fs.js的一段代码为例:
exports.write = function (path, content, modeOrOpts) {
var opts = modeOrOptsToOpts(modeOrOpts);
// ensure we open for writing
if ( typeof opts.mode !== 'string' ) {
opts.mode = 'w';
} else if ( opts.mode.indexOf('w') == -1 ) {
opts.mode += 'w';
}
var f = exports.open(path, opts);
f.write(content);
f.close();
};
现在我对exports 对象感到困惑。你可以在每个 PhantomJS 模块中找到它,但我找不到在哪里定义 exports 对象。
谁能给我一些关于定义exports对象的地方的建议?
不要与 NodeJS 中的 exports 混淆。它是 PhantomJS...
【问题讨论】:
-
stackoverflow.com/questions/9901082/… 这是一个通过要求注入到模块中的对象
标签: javascript phantomjs