# Banner Advertising

Mini Program advertising traffic main operating guidelines:Document address
Developers can use ad Component Creation Banner Advertising Component, Banner The ad component automatically pulls and displays ad data after it is created.

# Ad Size Settings

Banner Ads do not allow direct setting of style properties. The default width is 100% (width: 100%), and the height is automatically calculated proportionally, so developers can set the width of the ad outer component to adjust the size of the ad. The width of the outer component of the ad is not allowed to be less than 300px. When the width is less than 300px, the Banner The width of the ad is forced to 300 px.

/* The width of the outer assembly can be set to 100% or a specific value */
.adContainer {
  width: 100%
}
<view class="adContainer">
  <ad unit-id="xxxx" ></ad>
</view>

# Advertising event monitoring

Banner Ads are automatically pulled after they are created. Developers can use ad Component onload and onerror Event Monitor Ad Pull Success or Failure, Can Be Pulled Through onclose Event listening ads are turned off.

<view class="adContainer">
  <ad unit-id="xxxx"  bindload="adLoad" binderror="adError" bindclose="adClose"></ad>
</view>
Page({
  adLoad() {
    console.log('Banner Ad Loaded Successfully ')
  },
  adError(err) {
    console.log('Banner The advertisement failed, err)
  },
  adClose() {
    console.log('Banner Advertisingclosed')
  }
})

# Ad Timing Refresh

Developers can create Banner Incoming when advertising ad-intervals Parameter to achieve the timing refresh of the advertisement,ad-intervals The parameter is a number in seconds. Note: The auto-refresh interval cannot be less than 30 seconds, so that ad-intervals The parameter value must be greater than or equal to 30.

<view class="adContainer">
  <ad unit-id="xxxx"  ad-intervals="30"></ad>
</view>