【发布时间】:2016-02-04 10:08:33
【问题描述】:
当我使用 Polymer 的 Iron-ajax 元素时,我遇到了一个问题。
我有一个这样的自定义元素:
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<dom-module id="first-element">
<template>
<!-- Stylesheet-->
<style>
::host{
display:block;
}
</style>
<!-- Element content -->
<h1>
{{yolo}}
</h1>
<iron-ajax
auto
url="http://s3.amazonaws.com/codecademy-content/courses/ltp4/forecast-api/forecast.json"
handle-as="json"
on-response="handleResponse"
last-response="ajaxResponse"></iron-ajax>
<span>{{ajaxResponse.city_name}}</span>
</template>
<script>
Polymer({
is: "first-element",
properties: {
yolo: {
type: String,
value: 'YOLOOO'
}
},
handleResponse: function(){
console.log('Jobs Done')
}
});
</script>
</dom-module>
handleResponse 函数,也显示浏览器的开发者控制台,以便请求正常工作。数据绑定也正常工作,我还可以看到我的“yolo”属性值。
但是,它不显示数据,我也使用括号,例如 [[ajaxResponse.city_name]]
我该如何解决?感谢帮助!
【问题讨论】:
标签: ajax data-binding polymer