Polymer 操纵核心输入上的显示值和提交值

Polymer 操纵核心输入上的显示值和提交值,polymer,Polymer,我需要操作原始API数据中的值以显示给用户,并在通过API发送更新之前再次操作它们。我对每个值都使用核心输入,但是我很难设置初始值并绑定到正确的更新事件 <input id="host" is="core-input"> 还有JavaScript: setHost: { toDOM: function(record) { if(record.host === "@"){ return record.domain; } else {

我需要操作原始API数据中的值以显示给用户,并在通过API发送更新之前再次操作它们。我对每个值都使用核心输入,但是我很难设置初始值并绑定到正确的更新事件

<input id="host" is="core-input">
还有JavaScript:

  setHost: {
    toDOM: function(record) {
      if(record.host === "@"){
        return record.domain;
      } else {
        return record.host + "." + record.domain;
      }
    },
    toModel: function(value) {
      if(record.host === "@"){
        return record.domain;
      } else {
        return record.host + "." + record.domain;
      }
    }
  }

要设置初始值,我认为可以进行一次性绑定

<template is="auto-binding">
  <input is="core-input" type="text" value="[[foo]]">
</template>

<script>
  var tmpl = document.querySelector('template');
  tmpl.foo = 'bar';
</script>

var tmpl=document.querySelector('template');
tmpl.foo='bar';
似乎您试图采用的
committedValue
方法可能不受支持,因为您实际上无法写入
committedValue

设置此属性对输入值没有影响


最好是在更改时收听
或模糊时收听
(或两者兼而有之),处理更改,然后手动更新

,这感觉好像与聚合物的设计理念背道而驰。也许我们应该将讨论转移到Github票证或邮件列表上?哪一部分感觉违背了设计理念?如果您愿意,可以向polymer-dev发送一条消息,请进行编辑。如您所述,对于长格式讨论可能更容易
<template is="auto-binding">
  <input is="core-input" type="text" value="[[foo]]">
</template>

<script>
  var tmpl = document.querySelector('template');
  tmpl.foo = 'bar';
</script>