小程序 · 3种广告

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() {

  // 在页面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() {

  // 在页面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('激励视频 广告显示失败')
        })
    })
  }

},
复制代码

转载于:https://juejin.im/post/5cc661836fb9a031ff0d232b

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值