聚合物循环通过要冲压的元素阵列
Polymer loop through an array of elements to be stamped
我是否可以执行以下操作:
<template is="dom-repeat" items="[[blocks]]">
<[[item]]></[[item]]>
</template>
使用元素数组,例如:['my-element1'、'my-element2'、'my-element3']
感谢您的帮助。
您不能以这种方式构建您的标签,但是这个 hack 已经存在了一段时间:
<template is="dom-repeat" items="{{blocks}}">
<div inner-h-t-m-l={{item}}></div>
</template>
并让数组包含:
['<my-element1></my-element1>','<my-element2></my-element2>','<my-element3></my-element3>']
.
虽然我宁愿避免这种方法,因为它阻碍了元素之间的通信,我会使用常规 JS 来创建元素。
我是否可以执行以下操作:
<template is="dom-repeat" items="[[blocks]]">
<[[item]]></[[item]]>
</template>
使用元素数组,例如:['my-element1'、'my-element2'、'my-element3']
感谢您的帮助。
您不能以这种方式构建您的标签,但是这个 hack 已经存在了一段时间:
<template is="dom-repeat" items="{{blocks}}">
<div inner-h-t-m-l={{item}}></div>
</template>
并让数组包含:
['<my-element1></my-element1>','<my-element2></my-element2>','<my-element3></my-element3>']
.
虽然我宁愿避免这种方法,因为它阻碍了元素之间的通信,我会使用常规 JS 来创建元素。