Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

241.[微信小程序]微信小程序——插屏广告 #241

Open
webVueBlog opened this issue Jun 30, 2020 · 0 comments
Open

241.[微信小程序]微信小程序——插屏广告 #241

webVueBlog opened this issue Jun 30, 2020 · 0 comments

Comments

@webVueBlog
Copy link
Member

[微信小程序]

let interstitialAd = null
Page({
  onLoad() {
    if(wx.createInterstitialAd){
   //1.创建广告实例
      interstitialAd = wx.createInterstitialAd({ adUnitId: 'xxxx' })
   //3.监听广告,广告显示出来以后你要做的操作
      interstitialAd.onLoad(() => {
        console.log('onLoad event emit')
      })
   //其实可以不用管这个onError,它的作用是如果广告拉取失败,就提示你
      interstitialAd.onError((err) => {
        console.log('onError event emit', err)
      })
   //广告关闭时,触发。
      interstitialAd.onClose((res) => {
        console.log('onClose event emit', res)
      })
    }
//2.让广告显示出来
interstitialAd.show().catch((err) => {
  console.error(err)
})
}
 })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant