更改iron-list中现有项的bound属性的值

时间:2016-03-18 10:43:08

标签: javascript polymer polymer-1.0

我的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>

1 个答案:

答案 0 :(得分:2)