关于require重复加载的问题
来源:3-3 环境 & 调试 ——CommonJS3

Allen_Liu_1106
2017-11-06
代码稍微改了一下,test aa,bb中分别加了一句打印的输出:
test aa.js:
module.exports.test='A';
console.log('now in A');
const modB=require('./test bb');
console.log('modA',modB.test);
module.exports.test='AA';
test bb.js:
module.exports.test='B';
console.log('now in b');
const modA=require('./test aa');
console.log('modB',modA.test);
module.exports.test='BB';
这时候,当bb.js 循环require aa.js的时候,是不是只应该执行aa.js中已经被执行的内容(即 module.exports.test='A';
console.log('now in A');),这样的话,应该打印now in AA才对,但实际上没有打印,求教为啥?
写回答
2回答
-
多看一下我们视频的讲解,不要跳过去,实在不行查一下资料,很难两句话说明白
012017-11-08 -
Allen_Liu_1106
提问者
2017-11-06
now in A
now in bnow in A >>>>>>>>>>>>>>>>我认为是不是这里应该有这么一句,求老师指教
modB A
modA BB00
相似问题