2017-02-27 33 views
0

我正在嘗試爲我的自定義標記設置屬性。但它會給出錯誤。我附上錯誤和代碼段的截圖。無法在聚合物中設置屬性'_parent_dataUrl'undefined

<awts-est data-url$="{{dataUrl}}"></awts-est> 
properties: { 
dataUrl: { 
       type: String, 
       value: '', 
       reflectToAttribute: true, 
      }, 
} 
在演示

/index.html的

<awtt-ch data-url="http://abc.asdfg.com"></awtt-ch> 

回答

2

好吧,我回去過並重新創建你的構建。我相信這是你在基準水平上的。這成功地從dataUrl打印出數據。

的index.html

<html> 
    <head> 
     <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> 
     <link href="elements/awtt-ch.html" rel="import"> 
    </head> 
    <body> 
     <awtt-ch data-url="http://abc.asdfg.com"></awtt-ch> 
    </body> 
</html> 

元/ AWTT-ch.html

<head> 
    <link href="../bower_components/polymer/polymer.html" rel="import"> 
    <link href="/elements/awts-est.html" rel="import"> 
</head> 

<dom-module id="awtt-ch"> 
    <template> 
     <awts-est data-url$="{{dataUrl}}"></awts-est> 
    </template> 
</dom-module> 

<script> 
    Polymer({ 
     is: "awtt-ch", 
     properties: { 
      dataUrl: { 
       type: String, 
       notify: true, 
      } 
     }  
    }); 
</script> 

元/ AWTS-est.html

<html> 
    <head> 
     <link href="../bower_components/polymer/polymer.html" rel="import"> 
     <link href="/elements/awts-est.html" rel="import"> 
</head> 

<dom-module id="awts-est"> 
    <template> 
     <h1>Here's your data: <span>{{dataUrl}}</span></h1> 
    </template> 
</dom-module> 

<script> 
    Polymer({ 
     is: "awts-est", 
      properties: { 
       dataUrl: { 
        type: String, 
        notify: true, 
       } 
      }  
    }); 
</script> 
+0

不,這不是工作壓力太大。 – Ankita

+0

明天當我到辦公室並給你寫一個腳本時,我會看看。另外,只是爲了澄清和假設是不同的元素,是否正確? –

+0

是的,我在內使用 Ankita

相關問題