我需要在amp-lightbox,amp-accordion或其他amp-tag上插入外部应用程序。该应用程序插入到外部html中,因为该代码与amp-html代码不兼容。 这个问题的解决方案是什么? iframe在其他amp-中无法正常工作,当我将iframe插入放大器时 - 页面显示加载项目符号但不加载内容,如果我在其外部插入代码则可正常工作。
当用户点击特定区域或按钮时会启动此应用程序,因为第一次必须为用户隐藏iframe。
谢谢你
示例:
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-lightbox" src="https://cdn.ampproject.org/v0/amp-lightbox-0.1.js"></script>
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
<link rel="canonical" href="https://ampbyexample.com/components/amp-lightbox/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<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>
<style amp-custom>
.lightbox {
background: rgba(0,0,0,0.8);
width: 100%;
height: 100%;
position: absolute;
display: flex;
align-items: center;
justify-content: center;
}
.lightbox h1 {
color: white;
}
</style>
</head>
<body>
<amp-lightbox id="my-lightbox" layout="nodisplay">
<div class="lightbox" on="tap:my-lightbox.close" role="button" tabindex="0">
<amp-iframe width="350" height="300" layout="responsive" sandbox="allow-scripts allow-same-origin allow-popups" frameborder="0" src="https://www.xxxxxxxxx.com"></amp-iframe>
</div>
</amp-lightbox>
<button class="ampstart-btn caps m2" on="tap:my-lightbox" role="button" tabindex="0">
Open lightbox
</button>
</body>
</html>
该区域足以满足应用需求
答案 0 :(得分:3)
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
缺少。请参阅here。