amp-html - 将状态映射到 amp-list [src]

标签 amp-html amp-list amp-bind

我需要使用状态作为放大器列表的输入。但在此之前,我想映射状态(以执行一些数学或运算)。

当将数组的每个位置映射到一个对象并将其放入 src 时,我无法使其工作(代码 here ):

<amp-list [src]="menu.array.map(x => ({size_new: x.size.toUpperCase(), color_new: x.color.toUpperCase()}))" width="auto" height="100">
  <template type="amp-mustache">
    <div>
        {{size_new}} // {{color_new}}
    </div>
  </template>
</amp-list>

但是,如果我将每个数组位置映射到一个数组中(代码 here),我可以让它工作:

<amp-list [src]="menu.array.map(x => [x.size.toUpperCase(), x.color.toUpperCase()])">
  <template type="amp-mustache" width="auto" height="100">
    <div>
        {{0}} // {{1}}
    </div>
  </template>
</amp-list>

有什么建议吗?谢谢!

最佳答案

此问题最近已通过 https://github.com/ampproject/amphtml/pull/23762 解决

关于amp-html - 将状态映射到 amp-list [src],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53516148/

相关文章:

html - 是否可以将 amp-img 的尺寸移动到内联 css?

google-analytics - AMP 的 Google 分析 - 社会变量

javascript - 谷歌AMP : How to make an infinite-scroll in AMP?

reactjs - 带括号的自定义 React 属性

javascript - AMP-HTML 的自定义

blogger - 有没有办法在 AMP 列表中使用 Blogger?alt=Json 提要

amp-html - AMP 列表 - 如果我们没有收到 API 的响应,如何删除空白?

amp-html - 带有其他选项的放大器下拉菜单

html - amp bind 使用按钮更改状态

image - AMP HTML 如何支持图像优化?