exports = module.exports;
exports.a = 123; exports.b = 'hello'; exports.c = () => { console.log('ccc'); }; exports.d = { foo: 'bar' };
module.exports = { add: (x, y) => { return x + y; }, str: 'hello' };
module.exports = 'hello';
可是的话,由于只能导出单个成员,因此会出现覆盖状况,以下所示:spa
module.exports = 'hello'; // 以这个为准,后者会覆盖前者 module.exports = (x, y) => { return x + y; };