csdn/CSDN博文备份/VueGoogle广告的配置-143066260.md
2024-10-19 08:55:34 +08:00

3.1 KiB

前置条件:已经在Google AdSense 中 添加网站 并通过审核 同时已创建广告单元。


因 VUE 的 Script 配置问题,所以不能直接拷贝内容。


index.html 配置


添加 Google 广告的脚本。



//index.template.html
/* *
在head标签中添加 script
【 **** 】:你的发布商 ID
*/



//index.template.html
//在body标签中为window添加函数









2024-10-18_19-58-39




组件中


组件中添加应用。



onMounted(() => {
window.googlAdsense();
});



2024-10-18_20-00-52



为广告添加占位符。



//将广告单元代码添加到盒子中


class="adsbygoogle"
style="display: block"
data-ad-client="ca-pub-4797644559430915"
data-ad-slot="4417932244"
data-ad-format="auto"
data-full-width-responsive="true"
>





2024-10-18_20-00-16


https://www.isharkfly.com/t/vue-google/16438/1