Export multiple classes in ES6 modules

前端 未结 6 832
鱼传尺愫
鱼传尺愫 2020-11-28 18:42

I\'m trying to create a module that exports multiple ES6 classes. Let\'s say I have the following directory structure:

my/
└── module/
    ├── Foo.js
    ├──         


        
6条回答
  •  暖寄归人
    2020-11-28 19:08

    // export in index.js
    export { default as Foo } from './Foo';
    export { default as Bar } from './Bar';
    
    // then import both
    import { Foo, Bar } from 'my/module';
    

提交回复
热议问题