从子目录导出默认值

问题描述 投票:0回答:1

假设我有一个看起来像这样的文件结构

–Directory
--myComponent.js
––Subdirectory
–––fileA.js
–––fileB.js
–––index.js
––index.js

我的Directory/Subdirectory/index.js看起来像这样:

export { default as fileA } from './fileA';
export { default as fileB } from './fileB';

我的Directory/index.js看起来像这样:

export { default as myComponent } from './myComponent';
import * as _Subdirectory from './Subdirectory';
export const Subdirectory = _Subdirectory;

我的问题 - 来自Directory/index.js的第2行和第3行可以写成一行(就像第1行一样)?

javascript node.js ecmascript-6
1个回答
0
投票

是的,你可以组合这些线:

export { default as Subdirectory } from "./Subdirectory";
© www.soinside.com 2019 - 2024. All rights reserved.