0
我想建立一個數據類型的行爲,聽取屬性更新。 傾聽兒童財產變化的最佳方式是什麼?聚合物行爲聽取兒童財產變化
function do_something_when_property_updates(property_name) {
return {
// How to listen to property?
properties: {
property_name: {
// This behavior doesn't (and shouldn't) own the property
observer: foo
}
},
foo: function(value) {
// Update handler
}
};
}
Polymer({
is:'test-element',
properties: {
bar: {
type: Object
}
},
behaviors: [do_something_when_property_updates('bar')]
});