gpt4 book ai didi

javascript - 如何将 iron-input 双向绑定(bind)到 dom-repeat 的项目?

转载 作者:数据小太阳 更新时间:2023-10-29 05:15:13 24 4
gpt4 key购买 nike

我刚开始玩 Polymer 1.0,正在尝试对集合进行非常简单的绑定(bind)。我能够在 dom-repeat 中显示文本,但是 two-way 绑定(bind)到 iron-input 不起作用。我尝试了字符串数组和对象。运气不好。

<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/iron-input/iron-input.html">

<dom-module id="hello-world">
<template>
<ul>
<template is="dom-repeat" items="{{data}}">
<li>{{item.value}}</li>
</template>
</ul>

<ul>
<template is="dom-repeat" items="{{data}}">
<li><input is="iron-input" bind-value="{{item.value}}"></input></li>
</template>
</ul>

</template>
</dom-module>

<script>
Polymer({
is: "hello-world",

ready: function() {
this.data = [
{ value: "Hello" },
{ value: "World!" }
];
}
});
</script>

最佳答案

更改为:value="{{item.value::input}}"看这里:http://plnkr.co/edit/QWdCk7ReXxtdKndwPdqq

关于javascript - 如何将 iron-input 双向绑定(bind)到 dom-repeat 的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30748691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com