[英]Change the value of a bound property on an existing item in iron-list
我在iron-list
綁定了一個項目,當我更改對象的綁定屬性時,我希望看到更改反映在屏幕上,但是我沒有。 怎么了?
https://jsfiddle.net/ckqL3a3o/3/
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/1.2.3.2/lib/polymer/polymer.html">
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/1.2.3.2/lib/iron-list/iron-list.html">
<script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
<script src="https://google.github.io/traceur-compiler/bin/BrowserSystem.js"></script>
<script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>
<template is="dom-bind" id="app">
<div style="width: 500px; height: 300px; background: #eee; overflow: auto; float:left">
<iron-list items="{{data}}" as="item" style="width: 500px; height: 300px;">
<template>
<p><span>{{item.name}}</span> <span>{{item.value}}</span></p>
</template>
</iron-list>
</div>
</template>
<script type="module">
'use strict';
var app = document.querySelector('#app');
app.data = [{ name: 'item', value: 3 }];
setTimeout(() => app.data[0].value = 4, 2000);
</script>
您需要使用Polymers API修改Polymer的模型數據以得到通知
setTimeout(() => this.set('app.data.0.value', 4), 2000);
也可以看看
-https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#set-path
-https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#array-binding
-https://www.polymer-project.org/1.0/docs/devguide/properties.html#notifysplices
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.