2015-11-11 18 views
4

聚合物文件(https://elements.polymer-project.org/elements/iron-input),我發現:在聚合物中,爲什麼使用`<input is =「iron-input」>「而不是`<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}}">

它是否兼容,這使得它更容易填充?

回答

7

iron-input元素的源代碼中不包含任何HTML。這意味着,這樣做的:

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

不會產生頁面上的實際輸入的用戶進行交互。 iron-input元素實際上是您可以應用於標準HTML輸入的一組行爲。

相關問題