脚本标记包含无法在自定义 AMP 页面上解析的无效 JSON

The script tag contains invalid JSON that cannot be parsed on custom AMP pages

我在 Laravel 上制作自定义 AMP 页面,今天我收到搜索控制台错误:脚本标签包含无法解析的无效 json,但是当我检查 AMP 验证程序时,它显示代码有效。

代码:

<amp-analytics type="gtag" data-credentials="include">
    <script type="application/json">
    {
      "vars" : {
        "gtag_id": "UA-xxxxxx-xx",
        "config" : {
          "UA-xxxxxx-xx": { "groups": "default" }
        }
      }
    }
    </script>
</amp-analytics>

删除此代码后,我没有收到警告,也成功提交了验证请求。

这是URL:https://wordkosh.com/amp/english-hindi/administrator-meaning-hindi

我发现了同样的错误信息,我通过改变这个解决了:

<script type="application/json">

变成..

<script type="application/ld+json">

然后提交验证请求。 这对我有用。