gpt4 book ai didi

javascript - NodeJs : How to export all the modules and variables in a Javascript file?

转载 作者:太空宇宙 更新时间:2023-11-04 01:12:59 24 4
gpt4 key购买 nike

如何使用 NodeJS 导出 Javascript 文件中存在的所有模块和变量。假设我有一个包含 20 个函数和 20 个变量的 .js 文件,我需要一次导出所有函数和变量,而不是一一导出。我怎样才能实现这个目标?

最佳答案

你不能。您必须以某种方式明确命名它们。

如果 Amberlamps 的答案不可能(您想要它们位于基础级别),您仍然可以这样做:

module.exports = {
functionA: function () {
// TODO
},
functionB: function () {
// TODO
},
// the rest
};

关于javascript - NodeJs : How to export all the modules and variables in a Javascript file?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14579877/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com