显示模板中的两个值之一

Show one of the two values in the template

我有一个简单的元素:

<dom-module id="example-element">
  <template>
    <span>{{showAorB??}}</span>
  </template>
  <script>
  Polyemer({
    is: 'example-element',
    parameters: {
      a: String,
      b: String
    }
  });
</script>
</dom-module>

我是这样使用的:

<example-element a="{{a}}" b="{{b}}">

在我的场景中,ab 之一始终是 undefined

我感到困惑的是如何实现{{showAorB}}部分。基本上我想要的是 a || b.

我尝试过的:

实现这个的正确方法是什么?

使用函数语法 ({{showAorB(a,b)}}) 但在你的 properties 声明中(你显示 parameters 但它应该是 properties)给出 ab 虚假(但不是 undefined)值。像这样:

properties: {
  a: {
    value: ''
  },
  b: {
    value: ''
  }
},

实例:http://jsbin.com/jazava/edit?html,output