该功能表示是否是直接执行的脚本还是import来的。
node下有吗?
node下有吗?
1
guchengf Aug 7, 2014 var main = function(){
// main code } if (require.main === module) { main(); } |
2
SoloCompany Aug 7, 2014
@guchengf 我的习惯是用 process.mainModule, 然后刚才去查了下文档, 貌似两个用法都不在文档里面
|
3
magicdawn Aug 8, 2014
module有parent和childrens属性
if(module.parent) { //被require的时候 } |
4
ibudao Aug 8, 2014
|
5
xieren58 Aug 23, 2014
if(!module.parent) xxxxxxxxx
|