nodejs - js파일 include(import)
마스터욱
0
32
0
0
2021-09-29 04:25:25
common.js
const config = function(){
return{
'ttt1' : 1,
'ttt2' : 2,
'ttt3' : function(){
var self = this;
console.log(self.ttt2);
return '';
},
}
}
module.exports = {
config
}
=================================================
var common = require('./common.js');
console.log(common.config().ttt3());
나는 config 함수만 만들어서, 나름 객체지향으로 만든건데, 함수를 여러개 만들어서,
module.exports 에 여러개 추가해두 된다.