【发布时间】:2021-01-13 02:45:20
【问题描述】:
我有一个基本组件 - Emoji.jsx
import styled from 'styled-components';
const StyledEmoji = styled.div`
font-size: 6rem;
cursor: pointer;
&:not(:last-child) {
margin-right: 3rem;
}
`;
function Emoji({ content, handleClick }) {
return (
<StyledEmoji onClick={() => handleClick(content)}>{content}</StyledEmoji>
);
}
export default Emoji;
我正在扩展这个组件并在 EmojiBubble.jsx 中对其应用动画
import Emoji from './Emoji';
import styled, { keyframes } from 'styled-components';
const Bubble = keyframes`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
`;
const EmojiBubble = styled(Emoji)`
animation: ${Bubble} 6s ease-in-out;
`;
export default EmojiBubble;
但是,当我使用 EmojiBubble 组件时,动画不起作用
<EmojiBubble content={emoji} /> //Emoji not rotating
这里有什么问题?
【问题讨论】: