【发布时间】:2020-03-17 01:50:38
【问题描述】:
module.exports 如何处理没有键的对象?例如,如果我在test.js
const two = 2;
const three = 3;
module.exports = {two, three}; // Is the right-hand side an object? If so, where are its keys?
// It doesn't look like it's object destructuring.
在app.js
const test = require("./test");
console.log(test.two); // 2
console.log(test.three); // 3
【问题讨论】:
-
这不是
module.exports所特有的——这只是 ES6 中引入的对象创建的简写
标签: javascript node.js node-modules