[英]Import/ Exports in ES6
I have a file called index.js
that I'm importing other modules into, and exporting them using named exports: 我有一个名为index.js
的文件,我正在将其他模块导入其中,并使用命名的导出文件将其导出:
import { Card, Icon } from 'some-library';
import ButtonComponent from './Button';
export const Button = ButtonComponent;
My question is - how can I export those named imports from some-library
in the same file without changing their names? 我的问题是-如何在不更改文件名的情况下从同一some-library
中导出这些命名的导入?
If you want to import a named export and re-export it with that same name, do this: 如果要导入命名的导出并以相同的名称重新导出,请执行以下操作:
export { Card, Icon } from 'some-library';
If you want to import a default export and re-export it with some specific name, do this: 如果要导入默认导出并使用某些特定名称重新导出,请执行以下操作:
export { default as ButtonComponent } from './Button';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.