我正在尝试在 Nextjs 10.1 中使用 Emotion 11 的 CSS Prop 按照文档,我的 .babelrc 文件如下:
{
"presets": [
[
"next/babel",
{
"preset-react": {
"runtime": "automatic",
"importSource": "@emotion/react"
}
}
]
],
"plugins": ["@emotion/babel-plugin"]
}
Run Code Online (Sandbox Code Playgroud)
我的 Nextjs 页面:
/** @jsx jsx */
import { css, jsx } from '@emotion/react'
export default function testPage() {
const color = 'darkgreen'
return (<div
css={css`
background-color: hotpink;
&:hover {
color: ${color};
}
`}
>
This has a hotpink background.
</div>)
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
当运行时为自动时,不能设置 pragma 和 pragmaFrag。
如果我删除编译指示,/** …