admin管理员组文章数量:1313077
What are the differences between
export * as bar from 'foo'
and
export { default as bar } from 'foo'
In my particular case, I've tried both of the followings, they all work, wonder the underlying differences between them.
// echarts v5.0.0
export * as ECharts from 'echarts/lib/echarts.js'
export { default as ECharts } from 'echarts/lib/echarts.js'
babel.config.js
module.exports = {
// "@vue/cli-plugin-babel": "~4.5.0",
presets: ['@vue/cli-plugin-babel/preset'],
}
What are the differences between
export * as bar from 'foo'
and
export { default as bar } from 'foo'
In my particular case, I've tried both of the followings, they all work, wonder the underlying differences between them.
// echarts v5.0.0
export * as ECharts from 'echarts/lib/echarts.js'
export { default as ECharts } from 'echarts/lib/echarts.js'
babel.config.js
module.exports = {
// "@vue/cli-plugin-babel": "~4.5.0",
presets: ['@vue/cli-plugin-babel/preset'],
}
Share
Improve this question
edited Jan 7, 2021 at 5:32
Wenfang Du
asked Jan 5, 2021 at 1:41
Wenfang DuWenfang Du
11.5k13 gold badges76 silver badges113 bronze badges
3
-
2
They are absolutely not the same. They might have the same result depending on what
foo
exports (or further, what your transpiler or module loader does with it) - please post that as well. – Bergi Commented Jan 5, 2021 at 13:22 - Does this answer your question? Difference between import X and import * as X in node.js (ES6 / Babel)? – marzelin Commented Jan 5, 2021 at 13:45
-
@marzelin It helped, but it didn't cover the
export * as
syntax. – Wenfang Du Commented Jan 6, 2021 at 3:08
1 Answer
Reset to default 9This one exports all named exports and default export from foo
as bar
:
export * as bar from 'foo'
This one only exports default export from foo
as bar
:
export { default as bar } from 'foo'
本文标签: javascriptexport * as bar VS exportdefault as bar Stack Overflow
版权声明:本文标题:javascript - export * as bar VS export { default as bar } - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741863929a2401787.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论