2
我想在模块“B”的模块“A”中使用一些代码,但我不知道该怎么做。在属于另一个模块的模块中使用代码
我想这样做:
a.js
module.exports = {
hello : function(){
alert('helo world');
}
};
b.js
module.exports = {
start : function(){
alert(A.hello());
}
};
main.js
A = require("a");
B = require("b");
B.start();
,但我得到“A是没有定义的”。
谢谢!
因为'main.js'从不使用A,所以'main.js'中也不需要'require'('a')'。 – hunterloftis