require('module1') // 没有定义命名,如何使用?var module2 = require('module2') // 可以使用module2调用模块里的函数批量导入模块var models_path = __dirname + '/app/models'var walk = function(path) {
fs
.readdirSync(path)
.forEach(function(file) { var newPath = path + '/' + file
var stat = fs.statSync(newPath) if (stat.isFile()) { if (/(.*)\.(js|coffee)/.test(file)) {
require(newPath)
}
} else if (stat.isDirectory()) {
walk(newPath)
}
})
}
walk(models_path)这里导入的模块如何调用模块里的方法呢?如果这样无法使用模块那么这样可以批量导入并可以使用模块?
添加回答
举报
0/150
提交
取消