首页 > 解决方案 > 如何从命名模块导入中省略 .default

问题描述

我正在努力配置我的导入和导出,以便.default在我想选择要导出的内容而不是模块时不必使用。

它是如何导出的。

import * as Icon from './components/1_atom/icon/svgicon'
import * as Button from './components/1_atom/button/button'

export { Icon, Button }

export default Icon;

它是如何导入的

import { Button, Icon } from '@philipaarseth/simple-components';

如果我 console.log 按钮,这就是我得到的

模块对象

有没有办法可以改变我导出模块的方式,这样我就不必使用了Button.default

标签: javascriptecmascript-6module

解决方案


感谢 loganfsmyth 的评论:

答案只是改变

import * as Icon fromimport Icon from


推荐阅读