- 打开开发者工具黑屏,无法打开
[图片]
2020-05-12 - banner广告获取不到realHeight,导致无法定位banner的位置
let stageW: number = Laya.Browser.clientWidth; let stageH: number = Laya.Browser.clientHeight; if(!this.adWidth) this.adWidth = stageW; if (Laya.Browser.onMiniGame) { if (!BannerAd._ad) { let wx = Laya.Browser.window.wx; let ad = wx.createBannerAd({ adUnitId: 'adunit-b8de22bfb625f2cc', adIntervals: 30,//自动刷新时间 style: { left: (stageW - this.adWidth)/2, top: stageH - 90, width: this.adWidth } }); ad.onResize(() => { ad.style.left = (stageW - this.adWidth)/2; ad.style.top = stageH - ad.style.realHeight; }); ad.onError(err => { console.log(err); }) BannerAd._ad = ad; /********这里输出 BannerAn._ad.style.realHeight = undefined******/ console.log(BannerAd._ad.style.realHeight)//这里输出是 undefined BannderAd._ad.style 是有值的 console.log(ad.style.realHeight)//这里输出是 undefined ad.style 是有值的 }else{ console.log("广告宽度::",stageW,this.adWidth); BannerAd._ad.style.left = (stageW - this.adWidth)/2; BannerAd._ad.style.width = this.adWidth; /**********************这里这里这这里这里这这里这里这这里这里这这里这里这这里这里这这里这里这里*********************/ BannerAd._ad.style.top = stageH - BannerAd._ad.style.realHeight;//就是这里出现这个realHeight取不到 } BannerAd._ad.show(); } //以上是代码,由于需求是贴着底部显示广告,现在获取不到广告高度,所以就没法贴着底部,导致一直无法审核通过。
2019-12-19 - 急!小游戏的realHeight取不到值 迫使广告无法底部对齐贴边?
let stageW: number = Laya.Browser.clientWidth; let stageH: number = Laya.Browser.clientHeight; if(!this.adWidth) this.adWidth = stageW; if (Laya.Browser.onMiniGame) { if (!BannerAd._ad) { let wx = Laya.Browser.window.wx; let ad = wx.createBannerAd({ adUnitId: 'adunit-b8de22bfb625f2cc', adIntervals: 30,//自动刷新时间 style: { left: (stageW - this.adWidth)/2, top: stageH - 90, width: this.adWidth } }); ad.onResize(() => { ad.style.left = (stageW - this.adWidth)/2; ad.style.top = stageH - ad.style.realHeight; }); ad.onError(err => { console.log(err); }) BannerAd._ad = ad; }else{ console.log("广告宽度::",stageW,this.adWidth); BannerAd._ad.style.left = (stageW - this.adWidth)/2; BannerAd._ad.style.width = this.adWidth; /**********************这里这里这这里这里这这里这里这这里这里这这里这里这这里这里这这里这里这里*********************/ BannerAd._ad.style.top = stageH - BannerAd._ad.style.realHeight;//就是这里出现这个realHeight取不到 } BannerAd._ad.show(); }
2019-12-19