【问题标题】:How to implement Google Adsense on VuePress?如何在 VuePress 上实现 Google Adsense?
【发布时间】:2019-02-02 12:10:48
【问题描述】:

有没有办法在 VuePress 中轻松实现 Google Adsense?我找到的资源仅提供了Vue only 的“操作方法”。

【问题讨论】:

    标签: adsense vuepress


    【解决方案1】:

    您可以将以下行添加到您的 config.js 文件中

    head: [
        ['script', { src: "//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" }],
        ['script', {}, 
        '(adsbygoogle = window.adsbygoogle || []).push({  google_ad_client: <your code here>,  enable_page_level_ads: true });'],
    ],
    

    这将在你的 head 标签内添加代码。

    【讨论】:

      【解决方案2】:

      如果你不想直接修改配置,有一个使用 Google Adsense 的插件

      https://www.npmjs.com/package/vuepress-plugin-google-adsense

      module.exports = {
        plugins: [
          [
            'vuepress-plugin-google-adsense',
            {
              'google_ad_client': '', // ca-pub-0000000000000000
              'enable_page_level_ads': true
            }
          ]
        ]
      }
      

      【讨论】:

        猜你喜欢
        • 2018-02-09
        • 2020-11-10
        • 2016-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-13
        • 2011-10-22
        • 1970-01-01
        相关资源
        最近更新 更多