重新导出ES 6模块中的默认值 [英] Re-export default in ES 6 modules

查看:83
本文介绍了重新导出ES 6模块中的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ES6中,可以缩短以下代码.我有一个App.js文件和一个index.js.

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

index.js

import App from './App';

export default App;

类似这样的东西

index.js

export default App from './App.js'

推荐答案

如果使用 stage-1预设),您将可以使用以下代码重新导出默认设置:

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"

有关更多信息,请参见 ECMAScript提案.

For more information see the ECMAScript proposal.

另一种方式(没有此插件)是:

Another way (without this plugin) is:

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

这篇关于重新导出ES 6模块中的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆