【发布时间】:2021-05-13 12:27:19
【问题描述】:
我正在尝试将 CSS 关键帧动画添加到我的 Material UI styled 组件,但添加关键帧动画似乎会引发错误。这是我的代码的样子:
const PulsatingCircle = styled("div")(({
theme,
}) => ({
"@keyframes pulsate": {
from: {
opacity: 1,
transform: "scale(1)",
},
to: {
opacity: 0,
transform: "scale(2)",
},
},
background: theme.palette.primary.main,
borderRadius: "100%",
animation: "$plusate 1s infinite ease",
position: "absolute",
zIndex: -2,
}));
此代码返回以下错误:
TypeError: container.addRule(...).addRule is not a function
Array.onProcessStyle
src/optimized-frontend/node_modules/jss-plugin-nested/dist/jss-plugin-nested.esm.js:93
90 | }));
91 | } else if (isNestedConditional) {
92 | // Place conditional right after the parent rule to ensure right ordering.
> 93 | container.addRule(prop, {}, options) // Flow expects more options but they aren't required
| ^ 94 | // And flow doesn't know this will always be a StyleRule which has the addRule method
95 | // $FlowFixMe[incompatible-use]
96 | // $FlowFixMe[prop-missing]
有没有在这样的样式组件中使用@keyframes 的解决方案?
注意:我使用的是 Material UI 内置的 styles API,而不是样式化组件。
【问题讨论】:
-
你找到解决办法了吗?
-
这个运气好吗?
标签: css reactjs material-ui jss