如何绑定到元素的布尔属性.看来
How can I bind to a boolean property of an element. It seems this
<my-element a-property-of-type-boolean='{{someBoolean}}'></my-element>不起作用,但是当这样暴露时,我也找不到如何绑定它:
does not Work, but I also cant find out how to bind to it when it is exposed like this:
<my-element a-property-of-type-boolean></my-element>似乎可以选择将类型设置为Object而不是Boolean,但是我不确定这种方法的有效性
It seems an option is to set the type to Object instead of Boolean, but I am not sure how valid this approach is
谢谢:-)
推荐答案如果在元素上放置一个属性,则其相关属性将始终为true.例如:
If you put an attribute on your element, the related property it will always be true. For example in:
<my-element a-property-of-type-boolean='false'></my-element>a-property-of-type-boolean是真的.
因此,如果要在元素上使用布尔属性,我建议使用默认值false声明该属性,然后,如果需要将该值更改为true,则可以在其上添加属性元素.
So, if you you want to use a Boolean property on your element, I suggest to declare the property with the default value of false and then, if you need to change the value to true, you can add the attribute on you element.
您的Polymer原型:
Your Polymer prototype:
Polymer({ is: 'my-element', properties: { aPropertyOfTypeBoolean: { type: Boolean, value: false } } });您的元素:
<my-element a-property-of-type-boolean></my-element>更多推荐
在Polymer 1.0中,如何将数据绑定到元素的布尔属性?
发布评论