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')]
});