ES6,如何在一行中导出导入的模块? [英] ES6, how can you export an imported module in a single line?
本文介绍了ES6,如何在一行中导出导入的模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果可能,我希望以下一行:
-
import Module from './Module/Module;
-
export Module;
我尝试过以下操作,但似乎不起作用:
-
export模块从'./Module/Module;
解决方案<从'./Module/Module'导出{default as Module}的div>
;
是标准的ES6方式,只要你不需要模块
也可以在导出模块的内部。
导出模块从'./Module/模块;
是一种建议的ESnext方式,但只有在Babel中启用它才有效现在。
I'd like to the following but with a single line, if possible:
import Module from './Module/Module;
export Module;
I tried the following but it doesn't seem to work:
export Module from './Module/Module;
解决方案
export {default as Module} from './Module/Module';
is the standard ES6 way, as long as you don't need Module
to also be available inside the module doing the exporting.
export Module from './Module/Module;
is a proposed ESnext way to do it, but that only works if you've enabled it in Babel for now.
这篇关于ES6,如何在一行中导出导入的模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文