您没有设置onError函数,该函数用于处理广告拉取的异常。请至少处理两种情况:
- 当前 Bug 的表现(可附上截图)
- 预期表现
应该正常,不报错
- 复现路径
必现
- 提供一个最简复现 Demo
this.videoAd.load()
.then(() => this.videoAd.show())
.catch(err => {
console.log(err.errMsg)
this.videoAd.load()
.then(() => this.videoAd.show())
})
this.videoAd.onClose(res => {
// 用户点击了【关闭广告】按钮
// 小于 2.1.0 的基础库版本,res 是一个 undefined
if (res && res.isEnded || res === undefined) {
// 正常播放结束,可以下发游戏奖励
console.log(“正常播放结束,可以下发游戏奖励”)
this.gameinfo.resetLifeNumber()
this.gameinfo.resetView(ctx)
} else {
// 播放中途退出,不下发游戏奖励
console.log(“播放中途退出,不下发游戏奖励”)
}
})
this.videoAd.onError(err => {
console.log(err)
})
