javascript - 无法将 css 动画属性添加到组件
问题描述
我正在将一个函数传递给应该注入背景动画的材质 UI 组件。三元组工作正常,因为我能够注入基本的 CSS 样式,例如{ backgroundColor: "#3b69f2" }
. 任何帮助找出我在关键帧/动画代码上做错了什么都将不胜感激!
零件
<TableRow style={{ ...styleRowHiglight, ...styleActionable, ...styleRowActionHighlight }}>
功能
const styleRowActionHighlight = getter('matter', 'records', 'highlightRow')
===recordConfig['meta']['id'] ?
{
"@keyframes bgcolorchange": {
"99.9%": { backgroundColor: "blue" },
"100%": { backgroundColor: "blue" }
},
"@-webkit-keyframes bgcolorchange": {
"99.9%": { backgroundColor: "blue" },
"100%": { backgroundColor: "blue" }
},
"@-moz-keyframes bgcolorchange": {
"99.9%": { backgroundColor: "blue" },
"100%": { backgroundColor: "blue" }
},
"@-o-keyframes bgcolorchange": {
"99.9%": { backgroundColor: "blue" },
"100%": { backgroundColor: "blue" }
},
WebkitAnimation: "bgcolorchange 5s infinite",
MozAnimation: "bgcolorchange 5s infinite",
OAnimation: "bgcolorchange 5s infinite",
animation: "bgcolorchange 5s infinite",
}
:
{};
解决方案
当您指向动画名称时。尝试在关键帧名称之前使用 $ 符号,如下面的代码
WebkitAnimation: "$bgcolorchange 5s infinite",
MozAnimation: "$bgcolorchange 5s infinite",
OAnimation: "$bgcolorchange 5s infinite",
animation: "$bgcolorchange 5s infinite",
推荐阅读
- javascript - 如何在考虑服务器负载的同时制作多人 javascript 游戏作弊证明
- r - 如何使用“”、“”之类的分隔符
- php - 如何使用php从文件中读回加密的字符串
- mysql - MariaDB 中是否有等效于 sprintf('%+03d:00', $my_number) 的功能?
- c - 区分 uid 范围的 kill(-1,…) 和有针对性的 kill
- java - RAD - 如何在 websphere 应用程序服务器管理控制台中为 JAX-WS 添加用户名令牌
- php - WordPress:对自定义帖子类型的评论
- regex - 正则表达式匹配多行中最后一次出现的字符串
- selenium-webdriver - Selenium WebDriver - 无法连接到 Mozilla geckodriver
- r - 将多个不完整的列“汇总”为 1 个汇总列