我想创建config.ts
文件,该文件存储我的应用的全局值。
为此,我能够通过这种方式使用它。
module.exports.key = "My key";
但我需要输出大约20-30的多个值。
那有什么办法吗?所以我不必每次都写module.exports
......
答案 0 :(得分:0)
您可以这样做:
在 config.ts :
中export const Keys = {
KEY_1: 'KEY_1_VALUE',
KEY_2: 'KEY_2_VALUE'
};
然后在导入它的文件中,您可以执行以下操作:
import { Keys } from './config';
Keys.KEY_1 //return the value 'KEY_1_value'