我有一个数组buttonColors,其中有一组十六进制格式的颜色。 现在我想显示一组纸质按钮,每个按钮的颜色都存在于 ButtonColors 数组中。在Polymer 1.0中如何实现?
<template is="dom-repeat" items="{{buttonColors}}">
<paper-button style="background-color:{{item}}" >
<b>click me</b>
</paper-button>
</template>
上面的代码片段似乎不起作用。请帮忙。
最佳答案
您需要创建一个函数并按以下方式调用它
<template is="dom-repeat" items="{{buttonColors}}">
<paper-button style="{{computeStyle(item)}}" >
<b>click me</b>
</paper-button>
</template>
<script>
computedStyle:function(cl)
{
var s= "background-color:"+cl;
return s;
}
</script>
关于javascript - 如何从一系列颜色中动态更改 polymer 1.0 纸质按钮的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31732751/