在 AMP 列表中无法点击 AMP HTML 按钮



提前道歉 - 我认为这是某个地方的小错字,因为我确定我有这个工作......

问题的简短版本:在下面的 AMP HTML 中,两个按钮都会呈现,但只有 amp 列表之外的按钮是可点击的。

下面问题的较长版本,以防有用。

我正在尝试实现带有许多与时间相关的幻灯片的轮播。任意位置的其中一张幻灯片将与"现在"相关。

我希望用户能够单击一个按钮,该按钮将他们带到表示"现在"的幻灯片。

我正在从 json 端点获取与"现在"相关的轮播索引,然后打算在胡子模板中设置按钮的 ontap 事件以转到相关幻灯片。

我显示的按钮需要位于放大器列表中,因为这就是我检索 json 的方式,它告诉我要指向哪个幻灯片索引。但是只有当我将按钮放在放大器列表之外时,该按钮才能单击。

我很确定这是我愚蠢的事情,任何人都可以提供一些启示吗?

<!doctype html>
<html âš¡ lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="canonical" href="/article.html">
<link rel="shortcut icon" href="amp_favicon.png">
<script async custom-element="amp-fit-text" src="https://cdn.ampproject.org/v0/amp-fit-text-0.1.js"></script>
<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></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>
<!-- this button is clickable, and the event is fired: -->      
<button on="tap:carousel.goToSlide(index=1)" >Go to slide 1</button>

<amp-list width="auto" height="200" src="<<JSON ENDPOINT>>">
<!-- this button is not clickable so no event is fired: -->    
<button on="tap:carousel.goToSlide(index=1)" >Go to slide 1</button>

<template type="amp-mustache"> 
<amp-carousel layout="fill" type="slides" id="carousel"  >
<amp-fit-text width="100" height="500" >           carousel pos 1       </amp-fit-text>
<amp-fit-text width="100" height="500" >           carousel pos 2       </amp-fit-text>
</amp-carousel>
</template>
</amp-list>
</body>
</html>

有趣的是滑块是静态的,因为 amp-carusel 不会在 amp-list 中呈现 amp-img。

但是按钮在放大器列表下是可点击的

这是工作网址

Json Url 在放大器列表下呈现按钮:单击此处

法典:

<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="canonical" href="/article.html">
<link rel="shortcut icon" href="amp_favicon.png">
<script async custom-element="amp-fit-text" src="https://cdn.ampproject.org/v0/amp-fit-text-0.1.js"></script>
<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></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>
<amp-list width="auto" height="200" src="https://jsonblob.com/api/6345e24e-803b-11e8-82fe-f3dd1274ef25">
<template type="amp-mustache"> 
<button on="tap:carousel.goToSlide(index={{index}})" >Go to slide {{position}}</button>
</template>
</amp-list>
<amp-carousel layout="responsive" height="200" width="500" type="slides" id="carousel">
<amp-fit-text width="200"   height="200"   layout="responsive">Slider 1</amp-fit-text>
<amp-fit-text width="200"   height="200"   layout="responsive">Slider 2</amp-fit-text>
<amp-fit-text width="200"   height="200"   layout="responsive">Slider 3</amp-fit-text>
</amp-carousel>
</body>
</html>

最新更新