Re-export default in ES 6 modules

后端 未结 3 1621
独厮守ぢ
独厮守ぢ 2020-12-13 05:14

In ES6, is it possible to shorten the following code. I have an App.js file and an index.js.

index.js

impo         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 06:18

    If you use proposal-export-default-from Babel plugin (which is a part of stage-1 preset), you'll be able to re-export default using the following code:

    export default from "./App.js"
    

    For more information see the ECMAScript proposal.


    Another way (without this plugin) is:

    export { default } from "./App.js"
    

提交回复
热议问题