`export const` vs. `export default` in ES6

前端 未结 6 874
悲哀的现实
悲哀的现实 2020-11-22 08:50

I am trying to determine if there is any big differences between these two, other than being able to import with export default by just doing:

i         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 09:02

    From the documentation:

    Named exports are useful to export several values. During the import, one will be able to use the same name to refer to the corresponding value.

    Concerning the default export, there is only a single default export per module. A default export can be a function, a class, an object or anything else. This value is to be considered as the "main" exported value since it will be the simplest to import.

提交回复
热议问题