我正在使用 amp-list,我想根据我得到的结果获得一个动态高度。有办法吗?我无法完成它。
<amp-list src="request-url">
<template type="amp-mustache" id="amp-template-id">
...
</template>
</amp-list>
所有可用的布局都需要 amp-list 级别或父级别的维度。但是我不想指定高度。我的结果可以有 1 或 12 项。
最佳答案
AMP 中没有动态布局(这是为了避免在页面加载时重排,这是 AMP 的一大优势)。但是,如果需要(并且可用),amp-list 将自动占用更多空间。
你可以做以下三件事来支持这一点:
以下是官方文档对此的评价:
If amp-list needs more space after loading it requests the AMP runtime to update its height using the normal AMP flow. If AMP Runtime cannot satisfy the request for new height, it will display overflow element when available. Notice however, the typical placement of amp-list elements at the bottom of the document almost always guarantees that AMP Runtime can resize it.
来源:https://www.ampproject.org/docs/reference/components/amp-list
关于amp-html - 具有动态高度的放大器列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40884651/