Polymer iron ajax找不到generateRequest()-方法
我是Polymer的新手,尝试创建iron ajax的ajax调用。我遇到一个错误,Polymer iron ajax找不到generateRequest()-方法,polymer,iron-ajax,Polymer,Iron Ajax,我是Polymer的新手,尝试创建iron ajax的ajax调用。我遇到一个错误,generateRequest()未定义 聚合物1正在使用中 我使用以下命令安装了iron ajax:bower安装--save PolymerLabs/promise polyfill#1 如您所见,我用 我将其与一些例子进行比较,但没有发现错误。 有人有想法或解决方案吗 代码如下: <!-- @license Copyright (c) 2016 The Polymer Project Authors.
generateRequest()
未定义
聚合物1正在使用中
我使用以下命令安装了iron ajax:bower安装--save PolymerLabs/promise polyfill#1
如您所见,我用
我将其与一些例子进行比较,但没有发现错误。
有人有想法或解决方案吗
代码如下:
<!--
@license
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="shared-styles.html">
<link rel="import" href="../bower_components/promise-polyfill/promise-polyfill-lite.html">
<dom-module id="my-view2">
<template>
<style include="shared-styles">
:host {
display: block;
padding: 10px;
}
</style>
<div class="card">
<div class="circle">2</div>
<h1>View Two</h1>
<p>Demo output</p>
</div>
<template is="dom-repeat" items="[[repos]]">
<span>{{items.name}}</span>
</template>
<button on-click="setajax">Click me</button>
<iron-ajax
id="ajax"
url=""
params='{"type":"all"}'
handle-as="json"
on-response="hresponse"
debounce-duration="300" >
</iron-ajax>
</template>
<script>
Polymer({
is: 'my-view2',
setajax: function () {
this.$.ajax.url = "https://api.github.com/users/burczu/repos";
this.$.ajax.params= {"type":"all"};
this.$.ajax.generateRequest();
},
hresponse: function(request) {
console.log(request.detail.response);
console.log(this.$.ajax.lastResponse);
}
});
</script>
</dom-module>
:主持人{
显示:块;
填充:10px;
}
2.
视图二
演示输出
{{items.name}
点击我
聚合物({
是:‘我的观点2’,
setajax:function(){
这是。$.ajax.url=”https://api.github.com/users/burczu/repos";
this.$.ajax.params={“type”:“all”};
这是$.ajax.generateRequest();
},
hr响应:功能(请求){
日志(请求、详细信息、响应);
log(this.$.ajax.lastResponse);
}
});
您需要安装iron ajax
:
bower install --save PolymerElements/iron-ajax
然后,可以使用以下代码导入:
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
完成上述操作后,代码将正常工作。您需要安装
iron ajax
:
bower install --save PolymerElements/iron-ajax
然后,可以使用以下代码导入:
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
完成上述操作后,代码将正常工作