首页 > Web开发 > 详细

nodejs module/require

时间:2015-03-26 00:53:19      阅读:167      评论:0      收藏:0      [点我收藏+]

1. wrap up a module using module.exports, name the file to a.js

var fun1=function(){

var stylus = require(‘stylus‘);

this.hi=function(){
    console.log(‘hi‘);
}


}

fun1.prototype.hello=function(){
    console.log("abcdefg");
}


module.exports=fun1;

 

2. load module using rquire function

var a=require(‘./a‘);

var instanceA=new a();

instanceA.hi();

instanceA.hello();

 

nodejs module/require

原文:http://www.cnblogs.com/zyip/p/4367393.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!