Autocomplete / Autofill with Polymer input element

2019-07-04 16:55发布

I'm having an issue getting Chrome's autofill and/or autocomplete working with Polymer input elements, such as gold-email-input. I've tried setting the autocomplete attribute of the gold-email-input component to on and I've also tried setting it to email. The autofill box appears, but selecting an entry from the autofill selections does not populate the control. What am I doing wrong?

3条回答
ら.Afraid
2楼-- · 2019-07-04 17:25

Try wrapping your input elements in a form element. This works for me:

<form>
     <paper-input id="user"
                   autocomplete="email"
                   label="Username or email"
                   value="{{user}}"
      </paper-input>
      <paper-input id="pwd"
                   autocomplete="current-password"
                   label="Password"
                   value="{{pwd}}"
      </paper-input>
</form>
查看更多
Explosion°爆炸
3楼-- · 2019-07-04 17:31

You don't need to set the autocomplete attribute, as it's already set to autocomplete=email.

I think we need to see a sample of your code in context because the input automatically populates for me when I select the autofill suggestion:

enter image description here

jsbin

查看更多
走好不送
4楼-- · 2019-07-04 17:35
<form is="iron-form">
  <gold-email-input></gold-email-input>
</form>

This tends to work

查看更多
登录 后发表回答