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;
}
BannerAd._ad.show();
}
你好,小游戏相关问题麻烦在小游戏专区提问,我们有专门的人员处理
小游戏专区:https://developers.weixin.qq.com/community/minigame
BannerAd._ad.style.clientHeight:undefined