gpt4 book ai didi

reactjs - 组件选择器只能和 babel-plugin-emotion 一起使用 使用emotion时报错

转载 作者:行者123 更新时间:2023-12-04 04:29:41 25 4
gpt4 key购买 nike

我有一个样式组件,例如

export const UL = styled.ul`
list-style: none
`
export const Nav = styled.nav`
${UL}: {
margin-top: 40px;
}

background-color: #222;
padding: 0.35em 1.25em;


`

我运行以下命令来添加 babel-plugin-emotion
npm i --save-dev babel-plugin-emotion

我收到这个错误

enter image description here

我还需要做什么才能让插件与情感一起工作?

最佳答案

原来你可以删除模块 babel-plugin-emotion 并使用 emotion 提供的宏.

使用以下导入

import styled from "@emotion/styled/macro";

就是这样,你很高兴。

关于reactjs - 组件选择器只能和 babel-plugin-emotion 一起使用 使用emotion时报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61435282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com