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

457 ℃

功能介绍: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://m.ipkd.cn/webs_14428.html

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

2022年ES语法最新版本到几了
查看numpy版本小技巧
谷歌浏览器不预览直接打印解决方法
js获取当前时间年月日时分秒
网站长期不更新内容如何提高网站流量?