var name;exports.setName=function(thisName){ name=thisName;}exports.sayHello=function(){ console.log("hello"+name);}getModule.jsvar myModule=require('./module');myModule.setName('alex');myModule.sayHello();getModule2.jsvar myModule1=require('./module');myModule1.setName('tomm');var myModule2=require('./module');myModule2.setName('jimm');myModule1.sayHello();singleobject.jsfunction hello(){ var name; this.setName=function(thisName){ name=thisName; } this.sayHello=function(){ console.log('hello '+name); }};//exports.hello=hello;module.exports=hello;getSingleObject.jsvar hello=require('./singleobject'); var he=new hello(); he.setName("tom"); he.sayHello(); var ho=new hello(); ho.setName('jim'); ho.sayHello();
新闻热点
疑难解答