W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
小程序廣告流量主操作指引:文檔地址
開發(fā)者可以使用 ad 組件創(chuàng)建小程序視頻廣告組件,視頻廣告組件在創(chuàng)建后會(huì)自動(dòng)拉取廣告數(shù)據(jù)并顯示。暫時(shí)僅支持在同層渲染模式下使用,且不支持嵌套使用。
小程序視頻廣告不允許直接設(shè)置樣式屬性,默認(rèn)寬度為100%(width: 100%),高度會(huì)自動(dòng)等比例計(jì)算,因此開發(fā)者可以設(shè)置廣告外層組件的寬度調(diào)整廣告的尺寸。 廣告外層組件的寬度不允許小于屏幕寬度90%,當(dāng)寬度小于屏幕寬度的90%時(shí),視頻廣告組件的寬度會(huì)強(qiáng)制調(diào)整為屏幕寬度的90%。
/* 外層組件的寬度可設(shè)置成100%或具體數(shù)值 */
.adContainer {
width: 100%;
}
<view class="adContainer">
<ad unit-id="xxxx" ad-type="video" ad-theme="white"></ad>
</view>
小程序視頻廣告組件提供黑、白兩種主題樣式,開發(fā)者可以在創(chuàng)建視頻廣告時(shí)傳入ad-theme參數(shù)實(shí)現(xiàn)主題樣式選擇,ad-theme參數(shù)為字符串類型,參數(shù)值可選white, black
<view class="adContainer">
<ad unit-id="xxxx" ad-type="video" ad-theme="white"></ad>
</view>
<view class="adContainer">
<ad unit-id="xxxx" ad-type="video" ad-theme="black"></ad>
</view>
視頻廣告在創(chuàng)建后會(huì)自動(dòng)拉取廣告。開發(fā)者可以通過 ad 組件的 onload 和 onerror 事件監(jiān)聽廣告拉取成功或失敗,可以通過 onclose 事件監(jiān)聽廣告被關(guān)閉。
<view class="adContainer">
<ad unit-id="xxxx" ad-type="video" ad-theme="white" bindload="adLoad" binderror="adError" bindclose="adClose"></ad>
</view>
Page({
adLoad() {
console.log('小程序視頻廣告加載成功')
},
adError(err) {
console.log('小程序視頻廣告加載失敗', err)
},
adClose() {
console.log('小程序視頻廣告關(guān)閉')
}
})
小程序視頻廣告組件不適用于定時(shí)刷新參數(shù)ad-intervals
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: