新手求助JS报错:Cannot read property 'play' of undefined
constaudios=databus.resources.audiosconstscoreList=['score1','score2','score3','score...
const audios = databus.resources.audios
const scoreList = [
'score1',
'score2',
'score3',
'score4',
'score5',
'score6',
'score7',
'score8',
'score9',
'score10',
'score11',
'score12',
'score13',
'score14',
'score15',
'score16',
'score17',
'score18',
'score19',
'score20',
'score21'
]
var n
playScore() {
scoreList.currentTime = 0,
n = Math.round(Math.random() * 20 + 1);
const bb = scoreList[n]
console.log(bb)
audios.bb.play()
},
bb可以正常打印,把bb改成score1之类的也可以正常播放,为什么用bb就不行? 展开
const scoreList = [
'score1',
'score2',
'score3',
'score4',
'score5',
'score6',
'score7',
'score8',
'score9',
'score10',
'score11',
'score12',
'score13',
'score14',
'score15',
'score16',
'score17',
'score18',
'score19',
'score20',
'score21'
]
var n
playScore() {
scoreList.currentTime = 0,
n = Math.round(Math.random() * 20 + 1);
const bb = scoreList[n]
console.log(bb)
audios.bb.play()
},
bb可以正常打印,把bb改成score1之类的也可以正常播放,为什么用bb就不行? 展开
2个回答
展开全部
bb.play()方法中报的错吧,play()里怎么写的
更多追问追答
追问
export default {
playScore() {
scoreList.currentTime = 0,
n = Math.round(Math.random() * 20 + 1);
const bb = scoreList[n]
console.log(bb)
audios.bb.play()
},
}
引用就在场景中直接引用
music.playScore()
追答
你搜索一下,哪里有“.play”的代码,看看对吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询