let resource = null
return new Promise((resolve,reject)=>{
resourcesList.forEach(resName => {
if (resName.endsWith('.png')) {
resource = new Image()
resource.src = 'images/${resName}'
} else if (resName.endsWith('.mp3')) {
resource = new Audio()
resource.src = 'audio/${resName}'
}
resource.addEventListener('load', () => {
loadedCount++
}
})
显示TypeError: Cannot read property 'addEventListener' of null,
求大佬帮debug
我这个resName.endsWith('.png')直接报错了,TypeError: resName.endsWith is not a function。我直接服气了,什么问题啊?为什么不能用endsWith()?
没走进if和else if呗
已经解决了,走进了的