0
我試圖將應用路由的參數傳遞給未定義的自定義元素。我可以在文件中顯示該參數,但在自定義元素中,它沒有定義。以下是我的代碼,請幫助我檢查如何修復它。謝謝。聚合物通過自定義元素的路由數據未定義
在自定義元素文件中,getid
沒有定義。
我的文件
<app-route
route="[[route]]"
pattern="/:slug/:id"
data="{{routeData}}"></app-route>
<!-- display correctly -->
[[routeData.id]]
<myelement-http-get
id="getCategoryData"
getid="[[routeData.id]]"
geturl="http://localhost:9000/polymer/category/"
jsonobject="{{jsonobject}}"
failure="{{failure}}"></myelement-http-get>
自定義元素
<script>
Polymer({
is: 'myelement-http-get',
properties: {
geturl: String,
getid: String,
jsonobject: {
type: Object,
notify: true
},
failure: {
type: Boolean,
notify: true,
readOnly: true
}
},
ready: function() {
/* undefined found this.getid */
this.$.ajaxData.url = this.geturl + this.getid;
this.$.ajaxData.generateRequest();
},
handleResponse: function (data) {
this.jsonobject = data.detail.response;
}
});
</script>
感謝,這是部分正確。但是'觀察者:['_generateRequest(geturl,getid)']'當我得到第三頁時不能更新。 'geturl'總是顯示第二頁網址。 – ppshein