https://developers.weixin.qq.com/miniprogram/dev/api/InterstitialAd.html
先看看官方dome演示:
// 在页面中定义插屏广告
let interstitialAd = null
// 在页面onLoad回调事件中创建插屏广告实例
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-fff1adcd58106a6a'
})
}
// 在适合的场景显示插屏广告
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
关闭复制代码
很多朋友表示看不懂,所以不看他这个了,直接看我的dome:
onLoad() {
this.interstitialAd();
},
interstitialAd: function () {
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({ adUnitId: 'adunit-ba43b4bf0be6d9d4' })
}
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
},
这段代码的意思就是在页面初始化的时候,加载出弹窗,如果需要其它地方调用,可以直接把下面这段代码复制,然后在需要的地方this.interstitialAd();调用就好
interstitialAd: function () {
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({ adUnitId: 'adunit-ba43b4bf0be6d9d4' })
}
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
},
其实官方写的很清楚,如果看不懂,建议多看看js相关教程。