0

我正在尝试提交带有自定义元素的表单。我想知道是否可以序列化,或者有一种解决方法来获取该数据。

<iron-form>
  <form>
  <paper-input name="name" label="Name" required></paper-input>
  <br>
  <input type="checkbox" name="food" value="donuts" checked> I like donuts<br>
  <input type="checkbox" name="food" value="pizza" required> I like pizza<br>
  <paper-checkbox name="food" value="cheese" required>I like cheese</paper-checkbox><br>
  <paper-slider name="value" value="10"></paper-slider>
  <div class="output"></div><br>
  <button>Submit</button>
</form>
</iron-form>
<script>
const form = document.querySelector('iron-form');
  form.addEventListener('iron-form-presubmit', function(event) {
    event.preventDefault();
    this.querySelector('.output').innerHTML = JSON.stringify(form.serializeForm());
  });
</script>

Plunker --> http://plnkr.co/edit/QaGDuJfXmzTin2oclJnI?p=preview

4

0 回答 0