amp-consent 元素中的 amp-list 并不总是有效

amp-list within amp-consent element not always working

一般来说,我想按照本教程实施 amp-consent:

basic user consent

但由于某些原因,应该通过 amp-list 加载的元素并不总是出现在 amp-consent 元素中。

只要将 amp-list 块放在 amp-list 之外,它的内容就会立即可见。

为什么会这样以及如何显示 amp-list 内容以及提示-ui?

显然,AMP 对使用 amp-list 生成结果有一些内置限制,但没有指定任何特定操作,但您可以通过触发一个来解决这个问题。 承认这不是最好的解决方案,但它确实有效。

只需在您的 amp-consent 组件中添加另一个 div-元素,然后在源 div 容器中放置一个按钮(显示另一个 div 容器)。

on="tap:targetContainer.show,sourceContainer.hide" 

根据您应用的服务和结果量,调用您的端点生成的列表现在应该是可见的。

<div id="targetContainer" hidden class="message">    
    <amp-list width="auto" height="132" layout="fixed-height" src="yourEndPoint" class="m1">
      <template type="amp-mustache">
           <button class="button_select" on="{{onAction}}">{{label}}</button>
      </template>
    </amp-list>