web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

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

164 ℃
     

功能介绍: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
本文共计748个字,预计阅读时长5分钟
生活小工具,收录了80多款小工具
上一篇: WordPress用自定义代码实现更高级的分页功能
下一篇: 车牌号输入HTML模板下载
x 打工人ai神器