html - 在 Polymer 中,为什么要使用 `&lt;input is="iron-input">` instead of ` <iron-input>`?

标签 html polymer web-component

在 Polymer 文档 ( https://elements.polymer-project.org/elements/iron-input ) 中,我发现:

<input is="iron-input" bind-value="{{myValue}}">

而在另一个官方文档(https://www.polymer-project.org/1.0/docs/devguide/registering-elements.html#type-extension)中,我发现:

    <dom-module id="main-document-element">
      <template>
        <p>
          Hi! I'm a Polymer element that was defined in the
          main document!
        </p>
      </template>
      <script>
        HTMLImports.whenReady(function () {
          Polymer({
            is: 'main-document-element'
          });
        });
      </script>
    </dom-module>
    <main-document-element></main-document-element>

我只是想知道为什么第一个<input is="iron-input" bind-value="{{myValue}}">不能写成 <iron-input bind-value="{{myValue}}"> .

是为了兼容性,更容易polyfill吗?

最佳答案

iron-input 元素的源代码中不包含任何 HTML。这意味着做:

<iron-input bind-value="{{myValue}}">

不会在页面上产生实际的输入供用户交互。 iron-input 元素实际上是一组可应用于标准 HTML 输入的行为。

关于html - 在 Polymer 中,为什么要使用 `&lt;input is="iron-input">` instead of ` <iron-input>`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33647428/

相关文章:

html - 使内容占据整个屏幕宽度

polymer - Polymer 中的模板数据绑定(bind)中的 {{}} 和 [[]] 有什么区别?

html - 包含 Polymer 元素(Shadow DOM)的 DIV 的动态高度

jquery - 使用 JQuery 访问 Polymer 创建的 DOM

javascript - HTML 标题属性未显示在影子 dom 元素中

python - 对来自html标签的信息进行分类

html - 是否可以使 Chrome、FF 和 IE9 将显示值 tableXXX 相同?

html - 如何缩放我的 SVG 以适应 d3 中其容器 div 的大小?

javascript - D3js/Javascript 与 Dart

polymer - 如何从子元素更改应用程序路由位置