web建站教程
     
  1. 首页
  2. 前端UI组件库
  3. AI项目和框架
  4. 前端知识
  5. AI应用
  6. IT知识
  7. ComfyUI插件
  8. 地图大全
  9. 休息站

Vue项目如何接入谷歌联盟广告(Google Adsense)

933 ℃

功能介绍:Vue项目开发中在指定的地方接入谷歌联盟广告(Google Adsense),下面web建站小编给大家简单介绍一下具体实现代码!

1、在index.html首页加入script通用代码

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" ></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({});
</script>

2、新建AdComponent.vue通用模板

<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'  
}  
</script>  
  
<style scoped>  
</style>

3、在需要展示的地方插入

<template>
  <div>
    <adComponent></adComponent>
  </div>
</template>
<script>
import adComponent from '@/components/AdComponent.vue';  
export default {
  components: {
    adComponent
  },
}
</script>   

vue项目引入谷歌广告报Adsense错误:TagError: adsbygoogle.push() error: All ins elements...解决方法

标签: Google Adsense Vue联盟广告

上面是“Vue项目如何接入谷歌联盟广告(Google Adsense)”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_14428.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 首页 > vuejs
扣子空间 – 免费全能AI办公智能体
Trae:新一代免费的AI编程工具
日历:
上一篇:
下一篇:
x 打工人ai神器
x 扫一扫打开藏历小程序

打开微信“扫一扫”查看今日藏历!