css动画已经执行过一次如何再次执行?
.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') } }
在需要展示动画的地方调用此方法即可。
                    
                
                
            
        
浙公网安备 33010602011771号