ad-interstitial.md 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
### 插屏广告

插屏广告组件是由客户端原生的图片、文本、视频控件组成的;插屏广告与信息流或横幅广告相比展现尺寸更大,同样能够满足您对大量曝光和用户转化的需求。

![](https://vkceyugu.cdn.bspapp.com/VKCEYUGU-a90b5f95-90ba-4d30-a6a7-cd4d057327db/5dc1ce6b-b786-4175-aec5-dd2ab4a5e34c.png)


**平台差异说明**

|App|H5|微信小程序|支付宝小程序|百度小程序|字节跳动小程序|QQ小程序|快应用|360小程序|快手小程序|京东小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
d-u-a's avatar
d-u-a 已提交
12
|√(3.4.8+)|x|√(3.4.8+)|x|x|x|x|x|x|x|x|
13 14 15 16


**开通配置广告**

d-u-a's avatar
d-u-a 已提交
17
[开通广告步骤详情](https://uniapp.dcloud.net.cn/uni-ad.html#start)
18 19 20 21


### 语法

d-u-a's avatar
d-u-a 已提交
22
`<ad-interstitial></ad-interstitial>`
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66


**属性说明**

|属性名														|类型													|默认值		|说明																																									|平台差异	|
|:-																|:-														|:-				|:-																																										|:-				|
|adpid														|String&#124;Number&#124;Array|					|广告位id,如果传入的是数组,会从索引0开始请求失败后继续下一个,适用于已配置底价的逻辑|					|
|preload                          |Boolean                      |true     |页面就绪后加载广告数据                                                                  |          |
|loadnext													|Boolean											|false		|自动加载下一条广告数据																																	|					|
|v-slot:default="{loading, error}"|															|					|作用域插槽可以获取组件内部广告加载状态和加载错误信息																	|					|
|@load														|EventHandle									|加载事件	|																																											|					|
|@close														|EventHandle									|关闭事件	|																																											|					|
|@error														|EventHandle									|错误事件	|																																											|					|

**方法说明**

|方法名|说明|
|:-|:-|
|load|加载广告数据|
|show|显示广告|


HBuilder 基座的测试广告位 `adpid``1111111113`


简单示例

```html
<template>
  <view>
    <ad-interstitial adpid="1111111113" :loadnext="true" v-slot:default="{loading, error}">
      <button :disabled="loading" :loading="loading">显示广告</button>
      <view v-if="error">{{error}}</view>
    </ad-interstitial>
  </view>
</template>
```


完整示例

```html
<template>
  <view class="content">
study夏羽's avatar
study夏羽 已提交
67
    <ad-interstitial adpid="1111111113" :loadnext="true" v-slot:default="{loading, error}" @load="onadload" @close="onadclose" @error="onaderror">
68 69 70 71 72 73 74 75 76 77 78 79 80
      <button :disabled="loading" :loading="loading">显示广告</button>
      <view v-if="error">{{error}}</view>
    </ad-interstitial>
  </view>
</template>

<script>
export default {
  data() {
    return {
    }
  },
  methods: {
study夏羽's avatar
study夏羽 已提交
81
    onadload(e) {
82 83
      console.log('广告数据加载成功');
    },
study夏羽's avatar
study夏羽 已提交
84 85
    onadclose(e) {
		 console.log("onadclose",e);
86
    },
study夏羽's avatar
study夏羽 已提交
87
    onaderror(e) {
88
      // 广告加载失败
study夏羽's avatar
study夏羽 已提交
89
      console.log("onaderror: ", e.detail);
90 91 92 93 94
    }
  }
}
</script>
```
95 96 97

**错误码**

study夏羽's avatar
study夏羽 已提交
98
[错误码相关问题排查](https://uniapp.dcloud.net.cn/component/ad-error-code.html)