css動畫已經(jīng)執(zhí)行過一次如何再次執(zhí)行?
.shakeAnimate { animation: shakeAnimation 2s ease-in-out forwards; }
const showAnimation = () => { const box = document.querySelector('.box') if (box) { if (box.classList.contains('shakeAnimate')) { box.classList.remove('shakeAnimate') // 強制重繪 box.offsetWidth // eslint-disable-line no-unused-expressions } box.classList.add('shakeAnimate') } }
在需要展示動畫的地方調(diào)用此方法即可。

浙公網(wǎng)安備 33010602011771號