Polymer 当数组子属性更改时是否已计算绑定激发?
聚合物1。* 我正在尝试使用数组优化计算绑定的行为。我有FOO,但它经常向我开火 我将其优化为Polymer 当数组子属性更改时是否已计算绑定激发?,polymer,polymer-1.0,Polymer,Polymer 1.0,聚合物1。* 我正在尝试使用数组优化计算绑定的行为。我有FOO,但它经常向我开火 我将其优化为uploadState.value: <template is="dom-repeat" initial-count="1" index-as="index" items="{{uploadState}}"> <div hidden$="[[getState(uploadState.value)]]">FOO</div> 但它一
uploadState.value
:
<template is="dom-repeat"
initial-count="1"
index-as="index"
items="{{uploadState}}">
<div hidden$="[[getState(uploadState.value)]]">FOO</div>
但它一点也不着火。当值
属性更改时,如何使其在计算绑定中激发
另外,如何使用
this.get()
在值发生更改时获取该值?我在计算绑定中尝试了var upload=this.get(['uploadState.value',0])
,但它只是显示未定义(当它使用。*时)使用绑定uploadState.value的问题在于它不存在。您正在创建一个uploadState
数组,其中包含一个属性为value
的成员,该属性看起来更像uploadState.*.value
,但您并不想在所有值更改时都进行更改,只需一个问题,这样您就可以利用dom repeat
的项
绑定,这样您的代码就会像这样出现:
<template is="dom-repeat"
initial-count="1"
index-as="index"
items="{{uploadState}}">
<div hidden$="[[item.value]]">FOO</div>
</template>
使用bindinguploadState.value的问题在于它不存在。您正在创建一个uploadState
数组,其中包含一个属性为value
的成员,该属性看起来更像uploadState.*.value
,但您并不想在所有值更改时都进行更改,只需一个问题,这样您就可以利用dom repeat
的项
绑定,这样您的代码就会像这样出现:
<template is="dom-repeat"
initial-count="1"
index-as="index"
items="{{uploadState}}">
<div hidden$="[[item.value]]">FOO</div>
</template>
<template is="dom-repeat"
initial-count="1"
index-as="index"
items="{{uploadStates}}"
as="uploadState">
<div hidden$="[[uploadState.value]]">FOO</div>
</template>