title: AdCustom

sidebar_label: AdCustom

Banner 广告

支持情况:AdCustom - 图1 AdCustom - 图2 AdCustom - 图3

参考文档

类型

  1. ComponentType<AdCustomProps>

示例代码

  1. class App extends Component {
  2. render () {
  3. return (
  4. <AdCustom
  5. unitId=''
  6. adIntervals={60}
  7. onLoad={() => console.log('ad onLoad')}
  8. onError={() => console.log('ad onError')}
  9. onClose={() => console.log('ad onClose')}
  10. />
  11. )
  12. }
  13. }

AdCustomProps

参数 类型 必填 说明
unitId string 广告单元id,可在小程序管理后台的流量主模块新建
adIntervals number 广告自动刷新的间隔时间,单位为秒,参数值必须大于等于30(该参数不传入时 Banner 广告不会自动刷新)
onLoad CommonEventFunction 广告加载成功的回调
onError CommonEventFunction<AdProps.onErrorEventDetail> 当广告发生错误时,触发的事件,可以通过该事件获取错误码及原因,事件对象event.detail = {errCode: 1002}

API 支持度

API 微信小程序 H5 React Native
AdCustomProps.unitId ✔️
AdCustomProps.adIntervals ✔️
AdCustomProps.onLoad ✔️
AdCustomProps.onError ✔️