gpt4 book ai didi

angularjs - 排队 GPT 命令中的异常类型错误 : Cannot read property 'addService' of null

转载 作者:行者123 更新时间:2023-12-04 16:14:58 25 4
gpt4 key购买 nike

我在我的 angularjs 应用程序中使用了 adsesne 代码。在第一次加载应用程序时,当我动态切换内容时,广告工作正常,出现此错误。
Exception in queued GPT command TypeError: Cannot read property 'addService' of null site:stackoverflow.com .

这是我在 div 中加载的脚本。

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
googletag.defineSlot('/28379801/MWBanner320x50', [320, 50], 'div-adlocation').addService(googletag.pubads());
googletag.enableServices();
});
</script>
<!-- /28379801/MWBanner320x50 -->
<div id='div-adlocation' style='width: 320px; height: 50px; margin:auto'>
<script>
googletag.cmd.push(function() { googletag.display('div-adlocation'); });
</script>
</div>

任何可能的解决使用 angularjs 的方法?

最佳答案

我有同样的问题,看到你的帖子。仅在两周后,我才偶然发现,如果您使用相同的 adUnitPath 两次定义插槽,您会得到相同的错误。 .也许你有同样的问题。
解决方案
确保 adUnitPath只定义一次。为我检查这个最简单的方法是 console.log(<the adUnitPath>)googletag.defineSlot(...)称呼。在屏幕截图中,您可以看到两次尝试定义同一个插槽。但是,这是不可能的,因为 adUnitPath 必须是唯一的。
Example of the error and the double define action

关于angularjs - 排队 GPT 命令中的异常类型错误 : Cannot read property 'addService' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62347160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com