Ad
Banner ad.
Type
ComponentType<AdProps>
Examples
- React
- Vue
class App extends Component {
render () {
return (
<Ad
unitId=''
adIntervals={60}
onLoad={() => console.log('ad onLoad')}
onError={() => console.log('ad onError')}
onClose={() => console.log('ad onClose')}
/>
)
}
}
<template>
<ad
unit-id=""
ad-intervals="60"
@load="onLoad"
@error="onError"
@close="onClose"
/>
</template>
AdProps
Property | Type | Required | Description |
---|---|---|---|
unitId | string | Yes | d unit ID, which can be created via the Ad Host module in Mini Program Console. |
adIntervals | number | No | The interval between the automatic refresh of the advertisements in seconds, the value of the parameter must be greater than or equal to 30.(Banner ads are not refreshed automatically if this parameter is not set.) |
onLoad | BaseEventOrigFunction<any> | No | Callback used when an ad is loaded |
onError | BaseEventOrigFunction<onErrorEventDetail> | No | Callback used when ad loading failed. event.detail = {errCode: 1002} |
onClose | BaseEventOrigFunction<any> | No | Callback used when an ad is closed |
Property Support
Property | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
AdProps.unitId | ✔️ | ||
AdProps.adIntervals | ✔️ | ||
AdProps.onLoad | ✔️ | ||
AdProps.onError | ✔️ | ||
AdProps.onClose | ✔️ |
onErrorEventDetail
Param | Type |
---|---|
errCode | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 |
AdErrCode
An error code is obtained by executing the binderror callback.
Code | Exception | Cause | Solution |
---|---|---|---|
1000 | Call failed due to a backend error | This error is not caused by developers. | Ignore the error, and it will be automatically recovered after a period of time. |
1001 | Parameter error | The parameter is incorrectly used. |
|
1002 | Invalid ad unit | The spelling may be incorrect or the ad ID of another app may be used. | Visit mp.weixin.qq.com to confirm the ad ID. |
1003 | Internal error | This error is not caused by developers. | Ignore the error, and it will be automatically recovered after a period of time. |
1004 | No suitable ad | The ad does not appear every time. Maybe it is not appropriate to the user. | This is a normal case. In addition, you need to improve compatibility in this case. |
1005 | The ad component is being reviewed. | Your ad is being reviewed and therefore cannot be displayed. | Visit mp.weixin.qq.com to check the review status. In addition, you need to improve compatibility in this case. |
1006 | The ad component is rejected. | Your ad failed to pass the review and therefore cannot be displayed. | Visit mp.weixin.qq.com to check the review status. In addition, you need to improve compatibility in this case. |
1007 | The ad component is rejected. | Your advertising capability is suspended. ads cannot be displayed during the suspension. | Visit mp.weixin.qq.com to check the Mini Program ad suspension status. |
1008 | The ad unit is disabled. | The advertising capability in the advertising space is disabled. | Visit mp.weixin.qq.com to enable the display in the advertising space. |
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Ad | ✔️ |