我试图追随Wes Boss savascript30的教导,但当我试图把“Javascript Drumitoki”网站做成时,我无法发挥任何作用。 这里有适当的正确档案,但当我向关键者发出压力,试图发挥声望时,这一错误信息在我检查圣经时出现:
jsdrumkit.html:66 - 失业(许诺): 该元素没有佐证来源。
这是该网站的印章:
function playSound(e){
//querySelector() is just when you need a single return value
//audio[input] is an attribute selector, and it works just like its CSS counterpart.
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
if(!audio) return;
audio.currentTime = 0; //rewind the file to the start
audio.play(); //**line 66 in the site s code**
console.log(key);
key.classList.toggle( playing );
}
function removeTransition(e) {
if(e.propertyName !== transform ) return; //skip if it s not a transform
this.classList.remove( playing );
}
const keys = document.querySelectorAll( .key );
keys.forEach(key => key.addEventListener( transitionend , removeTransition));
window.addEventListener( keydown , playSound);
如果我甚至能够工作,我就失去了什么?