我尝试在Polymer元素中替换一个完整的对象(属性),我尝试了几种可能性,但实际上都没有...
这是我到目前为止所提出的:
prefill: function() {
randomChild(function(r) {
// Does not work
var t = Object.assign(this.child, r); // r is an existing Child-object
this.set("child", t);
// Does not work
this.child.firstName = r.firstName;
// Works
this.set("child.firstName", r.firstName);
// Also works
this.child.lastName = r.lastName;
this.notifyPath("child.lastName");
}.bind(this));
}
如何在不为每个子属性调用this.child
的情况下将r
替换为this.notifyPath("...")
?