export { default as Button } from './components/button';
- export:导出一个模块,以便其他文件可以导入它。
- default:指示导出的是该模块的默认值。
- as Button:将导出的默认值重命名为 Button,这样在其他文件中导入时可以使用这个名称。
- from ‘./components/button’:指定导入的模块路径,即从 ./components/button 文件中导入默认导出。
总结
这行代码的功能是将 ./components/button 文件中的默认导出作为 Button 导出,使其他模块能够通过 import { Button } from ‘…’ 来使用它。
import { Button } from '@/libs/core';
<div className="px-[16px]">
<Button onClick={confirm}>{t('confirm')}</Button>
</div>
CRACO
@ 被用作指向项目源代码(通常是 src 目录)的别名,需要配置