amp-html - 将状态映射到 amp-list [src]
问题描述
我需要使用状态作为 amp-list 的输入。但在此之前,我想映射状态(执行一些数学或运算)。
将数组的每个位置映射到一个对象并将其放入 src 时,我无法使其工作(此处的代码):
<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>
但是,如果我将每个数组位置映射到一个数组中(此处的代码),我可以使它工作:
<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>
有什么建议么?谢谢!
解决方案
推荐阅读
- react-native - latlng 不能为空 - 需要一个位置
- sql-server - 为什么脚本会卡在这个nodejs脚本中的连接上
- sql - 日期格式不正确时如何在 SQL 中查询今天的日期
- encryption - CryptoJS v3.1.2 SHA3 (512) 解密
- angularjs - AngularJS - 输入类型=“数字”对于非数字(NaN)不可清除
- python - Python(DataQuest):对在循环外部和内部声明列表感到困惑?
- database - 对生成的列进行分组的案例查询
- python - 在 python 中为 Hadoop Map Reduce 创建自定义可写键/值类型?
- if-statement - Google Sheet:如果输入的数字低于原始 Cell-B,如何将 Cell-A 替换为 Cell-B 中的数字?
- c++ - 清除或替换控制台输出