ES6`export * from import`? [英] ES6 `export * from import`?

查看:182
本文介绍了ES6`export * from import`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否使用ES6或ES7或者babel的语法,这样可以轻松地捆绑多个子文件组呢?

Is there a syntax using ES6 or ES7 or babel which will allow me to easily bundle together many groups of sub files?

例如:

./action_creators/index.js
./action_creators/foo_actions.js
./action_creators/bar_actions.js

有index.js导入foo和bar操作,然后重新导出它们,所以我可以

Have index.js import foo and bar actions, then re-export them, so I can

import {FooAction, BarAction} from './action_creators/index.js'

我不想记住/改变参考,如果我要更改我已经组织对象本身的文件。

I don't want to have to remember / change references if I were to change which file I've organized the objects themselves into.

推荐答案

是的, ES6支持直接导出导入的模块

export { name1, name2, …, nameN } from …;

export {FooAction, BarAction} from './action_creators/index.js'






您还可以使用 * 语法重新导出导入的模块的所有导出

export * from …;

export * from './action_creators/index.js';






有关MDN的更多信息

这篇关于ES6`export * from import`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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