AMP HTML 页面无效

AMP HTML Page not valide

您好,我正在尝试为 amp https://www.ampproject.org/ 整合我的页面。

我已经把文档中的例子复制粘贴到我的页面中了。

<!doctype html>
<html amp lang="en">
  <head>
    <meta charset="utf-8">
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <title>Hello, AMPs</title>
    <link rel="canonical" href="http://example.ampproject.org/article-metadata.html" />
    <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
    <script type="application/ld+json">
      {
        "@context": "http://schema.org",
        "@type": "NewsArticle",
        "headline": "Open-source framework for publishing content",
        "datePublished": "2015-10-07T12:02:41Z",
        "image": [
          "logo.jpg"
        ]
      }
    </script>
    <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
  </head>
  <body>
    <h1>Welcome to the mobile web</h1>
  </body>
</html>

我正在尝试检查我的页面是否被识别为有效页面。

所以我创建了一个新路由,并将参数放入我的 chrome 控制台中进行调试验证。

但是我有这个错误:

Powered by AMP ⚡ HTML – Version 1491601970987 http://local.dev/amp/actualites/test#development=1

validator.js:380 AMP validation had errors:

validator.js:380 http://local.dev/amp/actualites/test:28:0 The inline 'style' attribute is not allowed in AMP documents. Use 'style amp-custom' tag instead. (see https://www.ampproject.org/docs/guides/responsive/style_pages)

validator.js:380 http://local.dev/amp/actualites/test:28:69 The tag 'script' is disallowed except in specific forms.

validator.js:380 http://local.dev/amp/actualites/test:28:19029 The tag 'script' is disallowed except in specific forms.

该页面似乎无效。但是我不明白,我只是拿了示例文档!!!

我做错了什么?

https://www.ampproject.org/docs/guides/debug/validate

找到了。我正在使用 symfony,这是一个 php 框架。

在开发模式下,框架会在 DOM 中插入一个调试工具栏,其中包含内容 html、js 等...因此 AMP 无效。

要解决此问题,您可以在 config_dev.yml 文件或 运行 使用 app.php

的生产模式站点中禁用工具栏
web_profiler:
    toolbar: true