我有一个默认导出包含常量的对象的文件。我还想导出对象的每个属性。有没有办法做到这一点,不涉及全部写出来?
import keyMirror from 'keymirror';
// keymirror outputs an object with key = val. eg. {a: a, b: b, ...}
const types = keyMirror({
FREEFORM: null,
GRAPH_IMAGE: null,
...
});
export default types;
export const FREEFORM = types.FREEFORM;
export const GRAPH_IMAGE = types.GRAPH_IMAGE;
...
答案 0 :(得分:1)
不确定export
,但您可以使用单个解构分配
const {FREEFORM, GRAPH_IMAGE, ..} = types;