javascript - 是否可以在本地机器上测试Google客户评论徽章

标签 javascript google-api development-environment

所以我使用以下代码来实现客户评论徽章。

<script src="https://apis.google.com/js/platform.js?onload=renderBadge"
  async defer>
</script>

<script>
  window.renderBadge = function() {
    var ratingBadgeContainer = document.createElement("div");
    document.body.appendChild(ratingBadgeContainer);
   window.gapi.load('ratingbadge', function() {
     window.gapi.ratingbadge.render(
       ratingBadgeContainer, {
          "merchant_id": 42,
          "position": "BOTTOM_LEFT"
        });
    });
  }
</script>
<!-- END GCR Badge Code -->

<!-- BEGIN GCR Language Code -->
<script>
  window.___gcfg = {
    lang: 'en_US'
  };
</script>


<g:ratingbadge merchant_id=MERCHANT_ID></g:ratingbadge>​

但是是否有可能使其在本地计算机上运行?

另外,本地计算机是指在我的计算机上运行 Visual Studio 解决方案。因此它不在可公开访问的网站中。

干杯

最佳答案

好吧,我明白了,

事实证明,徽章不会在本地计算机上呈现 http://localhost

我从谷歌获得的客户评论代码也是通过谷歌标签管理器实现的。 经过分析,徽章未呈现,因此当我将客户评论代码添加到页脚(因此不通过标签管理器)时,它正在工作。

Conclusion

The google customer reviews code must be on the live server to work.(So not http://localhost) etc.

The code must be included directly in the theme files. NOT THROUGH GOOGLE TAG MANAGER

关于javascript - 是否可以在本地机器上测试Google客户评论徽章,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44938922/

相关文章:

javascript - 我们什么时候可以使用异步?

javascript - iOS/Javascript - 如何使用 Javascript 访问设备上的图像

api - 我可以在商业项目中使用 Google Weather API 吗?

python-3.x - google Drive api v3 文件上传错误

docker - 如何在 docker 容器内从头开始构建新应用程序?

javascript - 自动完成菜单上方的输入框 - Bootstrap 3

javascript - 使用 loadonce 时的 JQGrid 分组问题

node.js - Webpack 和 GoogleApis 端点路径问题

css - css 中的 MVC 内容文件夹 url 在本地主机和生产服务器之间呈现不相同

Laravel "Homestead Up"更新 VirtualBox 后无法启动虚拟机,Vagrant 表示它已经存在