我试图弄清楚为什么下面的代码在加载时会在控制台中给我这两个错误:
Uncaught Error: The error you provided does not contain a stack trace.
Uncaught (in promise) DOMException
playSound = () => {
let audioSound0 = new Audio(this.state.data[this.state.index].answerAudio0);
let audioSound1 = new Audio(this.state.data[this.state.index].answerAudio1);
audioSound0.addEventListener('ended', function() {
audioSound1.play();
})
audioSound0.play();
}
componentDidMount() {
this.playSound();
}
我可以运行具有其他功能的componentDidMount(),并且效果很好。
componentDidMount() {
console.log('test')
}
给我这两个错误的playSound函数是什么?
答案 0 :(得分:-1)
尝试使用componentWillMount