我想要实现的是创建一个包含多个函数的模块.
module.js:
module.exports = function(firstParam) { console.log("You did it"); },
module.exports = function(secondParam) { console.log("Yes you did it"); },
// This may contain more functions
Run Code Online (Sandbox Code Playgroud)
main.js:
var foo = require('module.js')(firstParam);
var bar = require('module.js')(secondParam);
Run Code Online (Sandbox Code Playgroud)
我firstParam遇到的问题是,它是一个对象类型,secondParam是一个URL字符串,但是当我有它时,它总是抱怨类型错误.
在这种情况下,如何声明多个module.exports?