纸张输入自动完成无法填写

时间:2016-05-25 18:56:27

标签: google-chrome polymer polymer-1.0 paper-elements

聚合物1.0 Chrome 50.0.2661.102

我正在尝试使用纸张输入启用Chrome自动填充功能。选择任一输入时,将显示标准的相应chrome自动填充提示列表,但是从列表中选择可用名称或电子邮件不会填充输入,它只会关闭chrome自动填充列表。

   <paper-input
     id="email"
     name="email"
     label="Email"
     type="email"
     autocomplete="email"
   ></paper-input>
   <paper-input
     id="password"
     name="password"
     label="Password"
     type="password"
     autocomplete="current-password"
   ></paper-input>

2 个答案:

答案 0 :(得分:2)

要使其正常工作,您需要切换到当前的阴影DOM(8-2-2018),浏览器不支持shadowDOM的自动填充。聚合物开发人员要求在以下错误跟踪器中提供此支持:

  1. https://bugs.webkit.org/show_bug.cgi?id=172567
  2. https://bugs.chromium.org/p/chromium/issues/detail?id=746593
  3. https://github.com/PolymerElements/paper-input/issues/554
  4. https://github.com/PolymerElements/iron-form/issues/197
  5. https://vlukashov.github.io/polymer-forms/#custom-in-shadow
  6. 要使其与shady DOM一起使用,请将以下代码放在webcomponents-loader.js脚本上方:

        <script>
            // Force all polyfills on
            if (window.customElements) window.customElements.forcePolyfill = true;
            ShadyDOM = {
                force: true
            };
    
            function idToChainedClass(poly, _this) {
                if (ShadyDOM) {
                    const allElements = poly.dom(_this.root).querySelectorAll('*');
                    let id;
                    for (var x = 0, len = allElements.length; x < len; x++) {
                        if (allElements[x].id) {
                            id = allElements[x].id;
                            allElements[x].removeAttribute('id');
                            allElements[x].classList.add(id);
                            _this.$[id] = poly.dom(_this.root).querySelector('.' + id);
                        }
                    }
                }
            }
        </script>
        <script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>
    

    并在idToChainedClass中使用ready()函数,无论您在哪里看到如下错误:  [DOM]找到具有非唯一id #input的x元素  您还可以随机化ID以使其唯一。遵循纸张输入提供的技术:  https://github.com/PolymerElements/paper-input/pull/609/files

答案 1 :(得分:1)

尝试在没有属性的表单标记中包装输入。像这样:

<form>
  <paper-input
     id="email"
     name="email"
     label="Email"
     type="email"
     autocomplete="email"
   ></paper-input>
   <paper-input
     id="password"
     name="password"
     label="Password"
     type="password"
     autocomplete="current-password"
   ></paper-input>
</form>