错误介绍:Vue项目开发中在指定的地方接入谷歌联盟广告(Google Adsense),报Uncaught TagError: adsbygoogle.push() error: All 'ins' elements in the DOM with class=adsbygoogle already have ads in them.错误,下面web建站小编给大家简单介绍一下解决方法!
具体解决方法如下:
//在AdComponent.vue组件里添加以下代码
let adsenseUnitLength = document.getElementsByClassName('adsbygoogle');
window.onload = function () {
for (let i = 0; i < adsenseUnitLength.length; i++) {
(adsbygoogle = window.adsbygoogle || []).push({});
}
};
完整代码如下:
//AdComponent组件
<template>
<div>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="YOUR_AD_CLIENT_ID"
data-ad-slot="YOUR_AD_CLIENT_ID"></ins>
</div>
</template>
<script>
export default {
name: 'AdComponent',
data() {
return {
}
},
mounted() {
//启动
let adsenseUnitLength = document.getElementsByClassName('adsbygoogle');
window.onload = function () {
for (let i = 0; i < adsenseUnitLength.length; i++) {
(adsbygoogle = window.adsbygoogle || []).push({});
}
};
}
}
</script>
<style scoped>
</style>
//在index.html引入通用script
Vue项目如何接入谷歌联盟广告(Google Adsense)
上面是“vue项目引入谷歌广告报Adsense错误:TagError: adsbygoogle.push() error: All ins elements...解决方法”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_14431.html
workflows工作流
去掉背景(抠图)comfyui工作流
一只黑色的小猫在童话森林里嗅着一朵发光的外星花
嘴唇丰满的漂亮女人
文生图工作流:一幅海底睡莲,碧海蓝天comfyui工
一个孤独的斗篷人物站在一座巨大的雕塑旁
树上挂着一只快乐香蕉ComfyUI工作流一
一只张大嘴巴露出锋利的牙齿正在咆哮的雪豹
一辆停在混凝土墙前运动型SUV捷豹概念车
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

纯CSS饼图效果
利用html5+css3实现滚雪球效果(附代码)
利用canvas画几个好玩的星云物种
一个包含老黄历、佛历、道历、星宿等数据的日历网站
纯css制作卡通头像(随鼠标转头)
一起去看流星雨(代码)
canvas黑洞漩涡(canvas+js)










