我需要使用状态作为放大器列表的输入。但在此之前,我想映射状态(以执行一些数学或运算)。
当将数组的每个位置映射到一个对象并将其放入 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/