Polymer 在模板中显示两个值之一
我有一个简单的元素:Polymer 在模板中显示两个值之一,polymer,polymer-1.0,Polymer,Polymer 1.0,我有一个简单的元素: <dom-module id="example-element"> <template> <span>{{showAorB??}}</span> </template> <script> Polyemer({ is: 'example-element', parameters: { a: String, b: String }
<dom-module id="example-element">
<template>
<span>{{showAorB??}}</span>
</template>
<script>
Polyemer({
is: 'example-element',
parameters: {
a: String,
b: String
}
});
</script>
</dom-module>
{{showAorB???}
多聚物({
是:'示例元素',
参数:{
a:弦,
b:字符串
}
});
我是这样使用它的:
<example-element a="{{a}}" b="{{b}}">
在我的场景中,a
或b
中的一个始终是未定义的
我所困惑的是如何实现{{showAorB}
部分。基本上,我想要的是像a | | b
这样的东西
我所尝试的:
- 计算属性/函数(
)-不起作用,因为它等待{{showAorB(a,b)}}
和a
都b
,在我的例子中,这意味着它将永远等待!==未定义的
-这太尴尬了{{a}}{{b}
{showAorB(a,b)}
),但在属性
声明中(您显示了参数
,但它应该是属性
)给出a
和b
错误(但不是未定义的
)值。像这样:
properties: {
a: {
value: ''
},
b: {
value: ''
}
},
实例: