将数组文字传递给聚合物计算绑定
Pass array literal to polymer computed binding
努力与研究
我想将数组文字传递给聚合物中的计算绑定。我的尝试是这样的:
if="[[ !isMatch(item.Type, ['Inbox', 'Review', 'Invalid']) ]]"
然而,isMatch
永远不会被击中。传递单个字符串工作正常。 The docs 提及字符串和数字字面量将起作用,但与数组无关。
问题
是否有允许我执行此操作的语法,或者当前的解决方案只是一系列嵌套的 if
?希望避免后者,因为它会降低性能。
Tomasz 的建议似乎是个不错的选择。我在我的聚合物属性部分添加了数组,然后在我的条件中使用它。
在聚合物属性中
umoveableCategories: {
type: Array,
readOnly: true,
value: ['Inbox', 'Review', 'Invalid']
}
更新条件
if="[[ !isMatch(item.Type, umoveableCategories) ]]"
努力与研究
我想将数组文字传递给聚合物中的计算绑定。我的尝试是这样的:
if="[[ !isMatch(item.Type, ['Inbox', 'Review', 'Invalid']) ]]"
然而,isMatch
永远不会被击中。传递单个字符串工作正常。 The docs 提及字符串和数字字面量将起作用,但与数组无关。
问题
是否有允许我执行此操作的语法,或者当前的解决方案只是一系列嵌套的 if
?希望避免后者,因为它会降低性能。
Tomasz 的建议似乎是个不错的选择。我在我的聚合物属性部分添加了数组,然后在我的条件中使用它。
在聚合物属性中
umoveableCategories: {
type: Array,
readOnly: true,
value: ['Inbox', 'Review', 'Invalid']
}
更新条件
if="[[ !isMatch(item.Type, umoveableCategories) ]]"