我正在我身边实施 AMP,但我门控错误:
除特定形式外,不允许使用标签“脚本”。请告诉我删除此错误。
amp 文档中不允许使用脚本。如果放大器组件符合您的要求,则最好使用它们。您可以在此处找到放大器组件的详细信息:https ://www.ampproject.org/docs/reference/components
最好的方法是在 amp-iframe 中使用 AMP 外部的脚本
在 head 内添加 amp-iframe 助手
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
使用 https://ampbyexample.com/components/amp-iframe/ 进行 iframe 调用,确保 sandbox="allow-scripts allow-same-origin"
您会注意到,如果您从同一来源调用 iframe,它将不起作用,因此您应该使用另一个来源
例如,如果您的域 example.com 使用
<amp-iframe width="500"
height="281"
layout="responsive"
sandbox="allow-scripts allow-same-origin"
allowfullscreen
frameborder="0"
src="https://iframe.example.com/script">
</amp-iframe>
在网页中没有 JavaScript 的情况下,并非所有功能都能按预期工作,但我承认 amp-html 使网站更快