我想创建一个带有功能属性的聚合元素,在成功响应时调用该属性。
我尝试了这个:
<foo-bar url="/api/getdata" succCallback="func"></foo-bar>
func function(){
alert('hi');
}
我尝试了这个:
<polymer-element name="foo-bar" attributes="url succCallback">
<template>
<core-ajax id="ajax" method="POST"
url="{{url}}"
contentType="application/json"
handleAs="json"
on-core-response="{{handleResponse}}"></core-ajax>
</template>
<script>
Polymer({
handleResponse: function(e){
var response = e.detail.response;
if (response.status === 'success') {
// call succCallback
this.fire(succCallback);
}
}
});
</script>
</polymer-element>
它不起作用。我怎样才能调用这个succCallback函数呢?谢谢!
windows[succCallback]();
,它也能正常工作,但我不知道是否会有任何副作用。 - Jie