gpt4 book ai didi

javascript - 在 AMP 页面中添加 Javascript

转载 作者:数据小太阳 更新时间:2023-10-29 04:30:46 25 4
gpt4 key购买 nike

请帮助我了解如何在 AMP(加速移动页面)中添加 javascript。我的要求是在 URL 中获得一个 ID。例如 localhost:8080/home?id=1。我想在我的 html 文件中访问该 id。

否则请告诉我如何添加任何 javascript 文件。

谢谢。

最佳答案

遗憾的是,您不能在 AMP 中添加任意脚本。来自 the specification ,在“HTML 标签”下,对于标签 script:

Prohibited unless the type is application/ld+json. (Other non-executable values may be added as needed.) Exception is the mandatory script tag to load the AMP runtime and the script tags to load extended components.

因此,如果您想在 AMP 中使用 JavaScript,则必须使用 AMP 的预定义 components .我没有看到可以满足您要求的组件。

关于javascript - 在 AMP 页面中添加 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43748634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com