ES6模块 - 使用公共别名命名导入

时间:2016-10-23 10:25:34

标签: javascript typescript module ecmascript-6

如果我理解正确,ES6模块导入不允许以下内容:

import { background, border, foreground } as colors from "./colors";

use(colors.background);
use(colors.border);
use(colors.foreground);

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/import

有什么解释原因吗?

我喜欢明确列出我想要导入的内容的想法。所以我不喜欢import * as colors from "./colors";,因为它不清楚我使用的是什么。

另一方面,这对我来说过于冗长:import { background as backgroundColor, border as borderColor, foreground as foregroundColor } from "./colors";

任何想法如何明确而不是不必要的冗长?

0 个答案:

没有答案
相关问题