2017-03-27 6 views
0

を示していないカスタムコンポーネント私はちょうどpolymer 2.0の学習を開始し、私は簡単なテストを実行します。あなたはすでに私を見ることができるようにポリマー2.0から

my-view1.html: 
<link rel="import" href="../../bower_components/polymer/polymer-element.html"> 
<link rel="import" href="shared-styles.html"> 

<dom-module id="my-view1"> 
    <template> 
    <style include="shared-styles"> 
     :host { 
     display: block; 

     padding: 10px; 
     } 
    </style> 

    <div class="card"> 
     <div class="circle">1</div> 
     <h1>View One</h1> 
     <p>Ut labores minimum atomorum pro. Laudem tibique ut has.</p> 
     <p>Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea.Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea.Cu mei vide viris gloriatur, at populo eripuit sit.</p> 
    </div> 
    </template> 

    <script> 
    class MyView1 extends Polymer.Element { 
     static get is() { return 'my-view1'; } 
    } 

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

long-calendar-app.html: 
<link rel="import" href="../../bower_components/polymer/polymer.html"> 
<link rel="import" href="shared-styles.html"> 
<dom-module id="long-calendar-app"> 
    <template> 
    <style include="shared-styles"> 
     :host { 
     display: block; 
     } 
    </style> 
    <h2>Hello [[prop1]]</h2> 
    <my-view1 name="view1"></my-view1><!--Added to test and see if it works--> 
    </template> 

    <script> 
    class MyApplication extends Polymer.Element { 
     static get is() { return 'long-calendar-app'; } 
     static get properties() { 
     return { 
      prop1: { 
      type: String, 
      value: 'long-calendar-app' 
      } 
     }; 
     } 
    } 

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

だけがstarter-kitからMyView1をコピーします<my-view1 name="view1"></my-view1><h2>Hello [[prop1]]</h2>の下に追加します。しかし、ブラウザではレンダリングされませんでした。

どうすれば解決できますか?

Update01:

私はちょうど私のデベロッパーコンソールをチェックして、私がmy-view1#shadow-rootていないように思える:スターターキットでは enter image description here

を、それは次のようになります。 enter image description here

これは、my-view1のレンダリングが行われていないことを意味しますか?

答えて

0

my-view1をlong-calendar-app.htmlにインポートする必要があります。

つまり<link rel="import" href="../my-view1/my-view-1.html">

+0

です。しかし、なぜ私は「スターターキット」の輸入品を見ていませんでしたか?彼らは何を違うのでしょうか? – sooon

+1

PSKでは、フラグメントを使用して、polymer.jsonファイルの詳細をレイジーロードします。 '" fragments ":[ " src/my-view1.html "、 " src/my-view2.html "、 "src/my-view3.html"、 "src/my-view404.html" ]、 ' – edje

関連する問題