1. Banner廣告
<div class="margin-xs padding-xs radius bg-white">
<ad unit-id="adunit-91f767d951338851" class="radius"></ad>
</div>
複製代碼
2. 插屏廣告
data() {
return {
interstitialAd: null
}
},
onLoad() {
if (wx.createInterstitialAd) {
console.log('wx.createInterstitialAd')
this.interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-7487758745f99b14'
})
}
if (this.interstitialAd) {
this.interstitialAd.show().catch((err) => {
console.error(err)
})
}
},
複製代碼
3. 激勵視頻廣告
data() {
return {
videoAd: null
}
},
onLoad() {
if (wx.createRewardedVideoAd) {
this.videoAd = wx.createRewardedVideoAd({
adUnitId: 'adunit-296656170310d2cd'
})
}
if (this.videoAd) {
this.videoAd.show().catch(() => {
this.videoAd.load()
.then(() => this.videoAd.show())
.catch(err => {
console.log('激勵視頻 廣告顯示失敗')
})
})
}
},
複製代碼