W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
小程序廣告流量主操作指引:文檔地址
開發(fā)者可以使用 ad-custom 組件創(chuàng)建 原生模板 廣告組件,原生模板 廣告組件在創(chuàng)建后會自動拉取廣告數(shù)據(jù)并顯示。
原生模板 廣告不允許直接設(shè)置樣式屬性,默認(rèn)寬度為100%(width: 100%),高度會自動等比例計(jì)算,因此開發(fā)者可以設(shè)置廣告外層組件的寬度調(diào)整廣告的尺寸。 廣告外層組件的寬度和具體模板相關(guān),具體可以參考模板編輯器文檔。
/* 外層組件的寬度可設(shè)置成100%或具體數(shù)值 */
.adContainer {
width: 100%;
}
<view class="adContainer">
<ad-custom unit-id="xxxx"></ad-custom>
</view>
原生模板 廣告在創(chuàng)建后會自動拉取廣告。開發(fā)者可以通過 ad-custom 組件的 onload 和 onerror 事件監(jiān)聽廣告拉取成功或失敗。
<view class="adContainer">
<ad-custom unit-id="xxxx" bindload="adLoad" binderror="adError"></ad-custom>
</view>
Page({
adLoad() {
console.log('原生模板廣告加載成功')
},
adError(err) {
console.log('原生模板廣告加載失敗', err)
}
})
開發(fā)者可以在創(chuàng)建 原生模板 廣告時傳入 ad-intervals 參數(shù)實(shí)現(xiàn)廣告的定時刷新,ad-intervals 參數(shù)為數(shù)字類型,單位為秒。注意:自動刷新的間隔不能低于30秒,因此 ad-intervals 的參數(shù)值必須大于或等于30。
<view class="adContainer">
<ad-custom unit-id="xxxx" ad-intervals="30"></ad-custom>
</view>
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: