定义元素属性值的方法:
Polymer({
is: 'x-custom',
properties: {
user: String,
isHappy: Boolean,
count: {
type: Number,
readOnly: true,
notify: true
}
},
ready: function() {
this.textContent = 'Hello World, I am a Custom Element!';
}
});
属性值说明:
Key | Details |
---|---|
type | Type: constructor (one of Boolean , Date , Number , String , Array or Object ) Attribute type, used for deserializing from an attribute. Unlike 0.5, the property's type is explicit, specified using the type's constructor. Seeattribute deserialization for more information. |
value | Type: boolean , number , string or function . Default value for the property. If |
reflectToAttribute | Type: boolean Set to |
readOnly | Type: boolean If |
notify | Type: boolean If |
computed | Type: string The value is interpreted as a method name and argument list. The method is invoked to calculate the value whenever any of the argument values changes. Computed properties are always read-only. See Computed properties for more information. |
observer | Type: string The value is interpreted as a method name to be invoked when the property value changes. Note that unlike in 0.5, property change handlers must be registered explicitly. The |