ES6 how to export all item from one file

前端 未结 2 379
醉酒成梦
醉酒成梦 2021-01-22 01:15

I want to export all methods of a file from another file.

currently I am doing this, and it works. How can I merge below two into 1 export expression

imp         


        
相关标签:
2条回答
  • 2021-01-22 01:38

    How can I merge below two into 1 export expression

    You cannot.

    ES2015 (and ES2016) does not provide a syntax that would allow you to import all the named exports from a file and export the object (with those as its properties) as default in a single statement.

    0 讨论(0)
  • 2021-01-22 01:41

    You cannot in ES2016. To create a module namespace object, you need to give it an identifier (like db) in your current module scope, and then re-export that. There's no way around it.

    There is however a stage 1 proposal to add the export * as default from … syntax you were trying.

    0 讨论(0)
提交回复
热议问题