es6 module 如何将引入的文件和其他文件一起导出?

// 文件结构
- Card
    - index.js
    - components
        - Footer.jsx
        - Header.jsx
        - wrapCard.js

我想在index.js中将这三个文件都同时导出,其中wrapCard中导出两个方法

// ....
export func1
export func2

index.js中该如何书写,可以在其他文件中直接访问到4个变量

// 大概这么引入
import {Footer, Header, func1, func2} from '@/Card'
阅读 2.4k
1 个回答

很简单,直接导入再重新导出即可

import Footer from './components/Footer.jsx';
import Header from './components/Header.jsx';
import {func1, func2} from './components/wrapCard.js';

export {
  Footer,
  Header,
  func1,
  func2,
};
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题