【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
let bannerAd = wx.createBannerAd({adUnitId: 'xxxx',style: {left: 10,top: 76,width: 320}})bannerAd.show()
bannerAd.show()
bannerAd.hide()
bannerAd.onError(err => {console.log(err)})
bannerAd.show().catch(err => console.log(err))
bannerAd.onLoad(() => {console.log('banner 广告加载成功')})bannerAd.show().then(() => console.log('banner 广告显示'))
let bannerAd = wx.createBannerAd({adUnitId: 'xxxx',style: {left: 10,top: 76,width: 320}})bannerAd.show()bannerAd.style.width = 400
style.width进行等比缩放,缩放的范围是 300 到屏幕宽度。屏幕宽度是以逻辑像素为单位的宽度,通过 wx.getSystemInfoSync() 可以获取到。let { screenWidth } = wx.getSystemInfoSync()
style.width小于 300 时,会取作 300。 当style.width大于屏幕宽度时,会取作屏幕宽度。 在组件内部会以此值为基准,根据 Banner 广告的标准尺寸,进行缩放。style.realWidth和style.realHeight到经过缩放后的宽和高。bannerAd.onResize(res => {console.log(res.width, res.height)console.log(bannerAd.style.realWidth, bannerAd.style.realHeight)})
bannerAd.onResize(res => {bannerAd.style.width = res.width + Math.random() * 10})
oldBannerAd.destroy()let newBannerAd = wx.createBannerAd({// ...})newBannerAd.show()
文档反馈