let interstitialAd = null;
onShow: function () {
this.initAd();
},
initAd: function () {
// 在页面onLoad回调事件中创建插屏广告实例
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-6772165b94d49af2'
})
interstitialAd.onLoad(() => { console.log("load interstitialAd successfully ") })
interstitialAd.onError((err) => { })
interstitialAd.onClose(() => { })
}
},
onHide: function () {
if(interstitialAd){
interstitialAd.destroy();
}
},
代码如上,在show函数中创建插屏广告,在onhide中摧毁这个插屏广告。 在本机调试没有问题。 但是用户报下面的错误。
a.destroy is not a function. (In 'a.destroy()', 'a.destroy' is undefined);at "pages/index/index" page lifeCycleMethod onHide function
onHide@https://pages/index/index.js:160:22
https://lib/WAService.js:1:1004738
https://lib/WAService.js:1:1004497
https://lib/WAService.js:1:1006233
https://lib/WAService.js:1:238108
emitInternal@https://lib/WAService.js:1:362485
https://lib/WAService.js:1:571146
https://lib/WAService.js:1:238108
emit@https://lib/WAService.js:1:362197
https://lib/WAService.js:1:368353
https://lib/WAService.js:1:238207
emit@https://lib/WAService.js:1:362197
https://lib/WAService.js:1:363391
https://lib/WAService.js:1:252407
m@https://lib/WAService.js:1:1720
你好,现在还会出现问题吗?