# BannerAd

Banner ad component. This is a native component at a higher layer than normal components. The banner ad component is hidden by default and you need to call BannerAd.show() to display it. The banner ad is uniformly zoomed according to the width set by the developer, and the zoomed size will be provided in the BannerAd.onResize() event.

# Properties

# Object style

The style of the banner ad component. The values of properties on style are set by the developer. The banner ad will be uniformly zoomed according to the width set by the developer. The actual zoomed size needs to be obtained via the BannerAd.onResize() event.

Property Type Description
left number The x-coordinate of the top-left corner of the banner ad component.
top number The y-coordinate of the top-left corner of the banner ad component.
width number The width of the banner ad component. The minimum value is 300, and the maximum value is the screen width (which can be obtained via wx.getSystemInfoSync()).
height number The height of the banner ad component.
realWidth number The actual width of the banner ad component after zoom.
realHeight number The actual height of the banner ad component after zoom.

# Methods

# Promise BannerAd.show()

Displays banner ads.

# BannerAd.hide()

Hides banner ads.

# BannerAd.destroy()

Terminates banner ads.

# BannerAd.onResize(function callback)

Listens on the banner ad size change event.

# BannerAd.offResize(function callback)

Un-listens on the banner ad size change event.

# BannerAd.onLoad(function callback)

Listens on the banner ad loading event.

# BannerAd.offLoad(function callback)

Un-listens on the banner ad loading event.

# BannerAd.onError(function callback)

Listens on the banner ad error event.

# BannerAd.offError(function callback)

Un-listens on the banner ad error event.