在我的网站中添加 YouTube 订阅按钮但出现此错误

Adding a YouTube subscribe button in my website but gives this error

所以我一直在尝试使用 YouTube API V3 给我的代码在我的测试网站上添加订阅按钮:

<script src="https://apis.google.com/js/platform.js"></script>

<div class="g-ytsubscribe" data-channelid="UCzfStpfCASIjJNK2xMNdJiw" data-layout="full" data-count="default"></div>

但是当我加载页面时,出现了这些错误:

> Failed to execute 'postMessage' on 'DOMWindow': The target origin
> provided ('file://') does not match the recipient window's origin
> ('null').                                     cb=gapi.loaded 0:49

> Failed to execute 'postMessage' on 'DOMWindow': The target origin
> provided ('file://') does not match the recipient window's origin
> ('null').                                     cb=gapi.loaded 0:48

如有任何帮助,我们将不胜感激!

刚刚测试了您的代码段,对我来说效果很好。我所做的只是将你的换成我的进行测试,它仍然有效。
我猜你与你的代码有冲突。 因此,请尝试将您的脚本标记放在顶部作为第一次调用。如果这不起作用,请尝试停用其他脚本以查看哪个脚本存在冲突。