[英]Polymer use Array for data binding
I have this dom-repeat template and I wonder how to pass an Array into attribute. 我有这个dom-repeat模板,我想知道如何将Array传递给属性。
<dom-module id="my-element">
<template>
<template is="dom-repeat" items="{{headers}}">
<span>{{item}}</span>
</template>
</template>
</dom-module>
<script>
Polymer({
is: "my-element",
properties: {
headers: Array
}
});
</script>
and then in an index.html
file, I bind it like this: 然后在index.html
文件中,我像这样绑定它:
<my-element headers="['abc', 'def']"></my-element>
I tried doing that but I nothing happened and I got the warning Polymer::Attributes: couldn't decode Array as JSON
我尝试过这样做,但我没有发生任何事情,我收到警告Polymer::Attributes: couldn't decode Array as JSON
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.