我需要具有 2 个类的元素。我从我的范围中收到的第一个和第二个类总是不变的。我如何在模板中连接它们?
<template>
<div class="b-item-additional-menu">
<template is="dom-repeat" items="{{menu}}" as="item">
<span class$="{{item.className}}"></span>
</template>
<mail-item-menu-dropdown></mail-item-menu-dropdown>
</div>
</template>
我需要结果<span class$="binded_class plain_class"></span>
谢谢!
最佳答案
您可以计算使用 computed bindings因为 Polymer 1.0 不支持字符串连接。
<span class$="{{computeClass(item.className)}}"></span>
然后您在元素的原型(prototype)中定义 computeClass
函数。
Polymer({
is: "my-element",
computedClass: function(class) {
return plain_class +" " +class;
}
关于javascript - 如何在 Polymer 中连接两个类(普通类和绑定(bind)类),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32723638/