从这个铁的Ajax元素:聚合物嵌套DOM重复预期阵列错误
<iron-ajax
id="ajax"
url="..."
handle-as="json"
verbose=true
last-response={{ajaxResponse}}
loading="{{cargando}}">
</iron-ajax>
我得到这个铁Ajax响应:
{
"id": "3",
"idcontenido": "9",
"imagenes": ["oneimage.png", "anotherimage.png"],
"tipo_imagen": "img-circle",
"html": "Lorem ipsum"
}
,我需要实现一个嵌套的DOM重复结构以迭代来自imagenes属性的项目。这是我的代码:
<template is="dom-repeat" items="[[ajaxResponse]]" as="registro">
<template is="dom-repeat" items="[[registro.imagenes]]" as="imagen">
<img class="[[registro.tipo_imagen]]" src="img/[[imagen]]" alt="" width="140" height="140" />
</template>
</template>
但我得到这个错误:
[dom-repeat::dom-repeat]: expected array for 'items', found Object {id: "3", idcontenido: "9", imagenes: Array[2], tipo_imagen: "img-circle", html: "Lorem ipsum"}
为什么? 谢谢!
您得到的响应不是数组,它的对象和dom-repeat仅适用于数组 – a1626
[\ [dom-repeat :: dom-repeat \]的可能重复:\ items \ ',找到对象](http://stackoverflow.com/questions/40824121/dom-repeatdom-repeat-expected-array-for-items-found-object) – a1626