ES6 module syntax: is it possible to `export * as Name from …`?

前端 未结 4 1712
小蘑菇
小蘑菇 2020-12-01 23:17

See question title. I found a great reference for the forms of export available, but I have not seen what I\'m looking for.

Is it possible to do somethi

4条回答
  •  死守一世寂寞
    2020-12-02 00:06

    // file: index.js
    // note, this doesn't have to be at the top, you can put it wherever you prefer
    import * as AllExportsFromThisModule from "./index.js"; // point this at the SAME file
    export default AllExportsFromThisModule;
    
    export const SOME_CONSTANT = 'yay';
    export const SOME_OTHER_CONSTANT = 'yayayaya';
    

提交回复
热议问题