2017-05-03 24 views
0

我是聚合物和紙張元素的新手。我只是製作新的空白聚合物應用程序,並嘗試運行紙質元素的一些示例。如何用某些紙元素示例構建聚合物應用程序

我使用this創建了我的空白聚合物應用程序。 然後我用涼亭添加紙張元素 - bower install --save PolymerElements/paper-elements

然後我複製粘貼此code

<paper-input always-float-label label="Floating label"></paper-input> 
<paper-input label="username"> 
    <iron-icon icon="mail" prefix></iron-icon> 
    <div suffix>@email.com</div> 
</paper-input> 

所以我的整個element.html看起來是這樣的:

<link rel="import" href="../../bower_components/polymer/polymer-element.html"> 
<link rel="import" href="/bower_components/paper-button/paper-button.html" > 
<link rel="import" href="/bower_components/paper-input/paper-input.html" >  
<link rel="import" href="/bower_components/iron-icons/iron-icons.html" > 

<dom-module id="allegro-combo-box"> 
    <template> 
    <style> 
     :host { 
     display: block; 
     } 
     paper-input { 
      max-width: 400px; 
      margin: auto; 
     } 
     iron-icon, div[suffix] { 
      color: hsl(0, 0%, 50%); 
      margin-right: 12px; 
     } 
    </style> 
    <h2>Hello [[prop1]]!</h2> 

     <paper-input always-float-label label="Floating label"></paper-input> 
     <paper-input label="username"> 
      <iron-icon icon="mail" prefix></iron-icon> 
      <div suffix>@email.com</div> 
     </paper-input> 

    </template> 

    <script> 
    /** @polymerElement */ 
    class Mextends Polymer.Element { 
     static get is() { return 'my-element'; } 
     static get properties() { 
     return { 
      prop1: { 
      type: String, 
      value: 'my-element' 
      } 
     }; 
     } 
    } 

    window.customElements.define(MyElement.is, MyElement); 
    </script> 
</dom-module> 

不幸的是這個碼贏沒有工作。只有<h2>Hello [[prop1]]!</h2>正在工作,紙張中的元素沒有。

如何解決? 我試圖在進口中添加「異步」,但這沒有幫助。

請幫忙。

這是在控制檯的一些錯誤:

Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry

Uncaught TypeError: Cannot read property 'nativeMethods' of undefined

回答

0

它看起來像你的import語句用於造紙的元素沒有正確的路徑。嘗試改變路徑如下:

<link rel="import" href="../../bower_components/paper-button/paper-button.html" > 
<link rel="import" href="../../bower_components/paper-input/paper-input.html" >  
<link rel="import" href="../../bower_components/iron-icons/iron-icons.html" > 
+0

路徑是正確的 –

+0

然後也許您的聚合物元素的路徑不正確?或者你有兩個bower_components目錄? –

+0

聚合物元素的路徑是好的,我只有一個目錄 –

相關問題