export 'default' (imported as '_construct') was not found in '@babel/runtime
时间: 2024-01-22 11:16:38 浏览: 109
根据提供的引用内容,这是一个关于导入样式和组件的问题。在React组件中,我们可以使用不同的方法来导入样式和组件。
方法一:使用import * as styles from './Button.treat.js'导入样式文件,并将样式应用于组件。
```javascript
import * as styles from './Button.treat.js';
export const Button = ({ text }) => (
<button className={styles.button}>{text}</button>
);
```
方法二:将样式附加到组件并将其导出,然后在组件中导入样式。
```javascript
/* styles */
export const Button = styled.button`...`
export const Text = styled.span`...`
export const Icon = styled.svg`...`
export const PrimaryButton = styled.button`...`
export const SecondaryButton = styled.button`...`
/* react component */
import { Button, Text, Icon, PrimaryButton, SecondaryButton } from 'styles.js'
```
这两种方法都可以用于导入样式和组件,具体使用哪种方法取决于个人偏好和项目需求。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)