我有对象数组和属性,我的 dom-repeat 结构如下所示
<template is="dom-repeat" items="{{arrayOfObj}}"> //first dom repeat
<span>[[myProperty]]<span> //here also its not updating
<template is="dom-if" if="[[_checkSomeCondition()]]"> //calling method from dom-if
<span>[[myProperty]]<span> //here its not getting updated value
</template>
</template>
我有一处房产
properties:{
myProperty:{
type:Boolean
}
}
每次 dom-repeat 迭代时都会调用我的函数
_checkSomeCondition:function() { //I'll check and set property
if(some condition){
this.myProperty = true;
return true;
}
else{
this.myProperty = false;
return true;
}
console.log(this.myProperty); //I'll get the updated value on console
}
但它在屏幕上没有改变!它将显示它第一次在 _checkSomeCondition 中设置的任何数据!但在控制台中它的更新
为了进行测试,我插入了一个按钮,在点击该按钮后渲染了所有 dom-repeat,我调用了一些函数,当我更改值时,它会随处反映出来
this.myProperty = true;
但是为什么当 dom-repeat 调用的函数内部的值发生变化时它不起作用?我尝试了所有 3 种更新对象的方法
Plunker:https://plnkr.co/edit/iAStve97dTTD9cv6iygX?p=preview https://plnkr.co/edit/iAStve97dTTD9cv6iygX?p=preview