首页 > 解决方案 > 如何使用animejs制作动画?

问题描述

这是 HTML 中真正重要的部分:-

<div id = 'buttons'>
            <a href = 'https://discord.com/api/oauth2/authorize?client_id=775316623220277248&permissions=391232&scope=bot' target = '_blank'>
                <button id = 'invbutton'><i class="fab fa-discord fa-3x"></i>Invite</button>
            </a>
            <button>Support</button>
</div>

这是JS:-

var buttons = document.getElementsByTagName('button');

for (i = 0; i < buttons.length; i++){
    let current_button = buttons[i];
    buttons[i].addEventListener('mouseenter', function () {
        console.log(current_button)
        anime({
            target: current_button,
            scale: 2,
            translateX: 500,
            duration: 5000
        })
        console.log("temp")
    })
}

我已经在 HTML 文件的末尾建立了脚本。脚本控制台正确记录了两个时间,但没有出现动画

标签: javascriptanimationdom-events

解决方案


这是一个错字。它应该targets不是target


推荐阅读