我正在尝试双向绑定到本机元素,并且在更改时不更新 DOM 时遇到了一些问题。
如果我有一个简单的属性,它可以正常工作:
<input type="text" value="{{myData::input}}">
当我绑定到一个新的对象实例并通过 javascript 更新绑定时,DOM 没有更新:
...
<input type="text" value="{{myData.bar::input}}">
<button type="button" on-click="changeBar">Update Me!</button>
...
var Foo = function(){
this.bar = "polymer";
}
Polymer({
is: 'my-object',
properties: {
myData : {
type: Object,
notify: true,
readOnly: false
}
},
ready: {
this.myData = new Foo();
},
changeBar: function(){
this.myData.bar = "poly";
}
当我检查this.myData.bar
时,它会显示出来= "poly"
。但是,DOM 仍然显示polymer
. 此外,更改的事件不会冒泡到父组件。
我还尝试以几种不同的方式编写 javascript Foo 模块。
聚合物版本:1.0.5/1.0.6
提前致谢!