今天我遇到了一个奇怪的问题,这个例子将解释一切:
function animate(arg) {
console.log(arg);
}
<button onclick="animate('foo')">
Run
</button>
最佳答案
根据 MDN,Element.animate()
是一个内置的实验函数:
The
Element
interface'sanimate()
method is a shortcut method which creates a new Animation, applies it to the element, then plays the animation. It returns the created Animation object instance.
在你的例子中,它变成了window.animate()
,它占用了一个不同的函数。
关于javascript - 无法命名函数 "animate"是什么原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43540510/