在ad组件加style或者在wxss中修改都没有效果。
麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题
let { screenWidth } = wx.getSystemInfoSync();ad = wx.createBannerAd({ adUnitId: 'xxxxxxxxx', style: { left: 0, top: 0, width: 0, height: 0 } });
= wx.createBannerAd({ adUnitId:
'xxxxxxxxx'
, style: { left: 0, top: 0, width: 0, height: 0 } });
ad.onResize(() => { ad.style.width = screenWidth * 0.6; ad.style.left = (screenWidth - ad.style.realWidth) / 2; ad.style.top = screenHeight - ad.style.realHeight; });
.onResize(() => { ad.style.width = screenWidth * 0.6; ad.style.left = (screenWidth - ad.style.realWidth) / 2; ad.style.top = screenHeight - ad.style.realHeight; });
你把这段代码替换到你的代码中去试试