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