【发布时间】:2023-04-06 01:40:01
【问题描述】:
我正在尝试实施 amp-list 以根据用户来自哪里允许使用不同的货币。我已经实现了 amp-list 元素并创建了一个 JSON 文件(这是一个 CORS url),其中包含使用正确语法的数据。
但是 amp-list 不打印数据,而是打印一个空白区域。 HTML 模板是:
<amp-list width="auto"
height="50"
layout="fixed-height"
src="/amp-price/57938">
<template type="amp-mustache">
<p class="price align-center {{test}}">{{price}}</p>
</template>
</amp-list>
JSON 响应是:
{"items": [{"price": "\u00a321.59", "test": "test"}]}
但是渲染出来的 HTML 是:
<amp-list width="auto" height="50" layout="fixed-height" src="/amp-price/57938" class="i-amphtml-element i-amphtml-layout-fixed-height i-amphtml-layout-size-defined i-amphtml-layout" aria-live="polite" style="height: 50px;">
<template type="amp-mustache">
<p class="price"> - </p>
</template>
<div class="i-amphtml-fill-content i-amphtml-replaced-content" role="list"></div></amp-list>
JSON 响应包含所有正确的 AMP 标头,我在控制台中没有收到任何 AMP 错误。
我还关注了页面源中的 src 链接,它转到了正确的 URL。
我缺少一些简单的东西吗?
【问题讨论】:
-
您可以添加指向示例页面的链接吗?另一件事:您是否在标头中导入 amp-mustache 扩展?
-
@DHiskett 检查我的答案希望这对你有帮助。