V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
saytom
V2EX  ›  Vue.js

请教个 vue 中加载 google admanger 的问题

  •  
  •   saytom · May 11, 2021 · 1416 views
    This topic created in 1816 days ago, the information mentioned may be changed or developed.

    我在页面 A 和 B 中配置了谷歌广告代码,使用<route-link>在 AB 页面相互访问跳转的时候提示

    Exception in queued GPT command TypeError: Cannot read property 'addService' of null

    输入强制刷新浏览器就可以正常显示,把<route-link>换成<a>或者window.location就可以正常显示。 网上搜了下像是浏览器跳转重复渲染了谷歌的广告对象或者变量已经在缓存中了。

    methods:{
            initGGAd(){
                window.googletag = window.googletag || {cmd: []};
                googletag.cmd.push(function() {
                    googletag.defineSlot('XXndd-yst', ['fluid'], 'divXX-0').addService(googletag.pubads());
                    googletag.pubads().enableSingleRequest();
                    googletag.pubads().collapseEmptyDivs();
                    googletag.enableServices();
                });
                googletag.cmd.push(function() { googletag.display('div-gpt-XX'); });
            }
        },
        created() {
          this.initGGAd()
        }
    

    有哪位朋友了解怎么处理的不?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2393 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 11:41 · PVG 19:41 · LAX 04:41 · JFK 07:41
    ♥ Do have faith in what you're doing.