加载更多的内容上的按钮点击在聚合物
Load more content on button click in Polymer
在聚合物中,我试图延迟加载DOM中的内容。有一个例子,这样做的滚动使用iron-scroll-threshold
。但是如何实现相同的按钮点击??
<head>
<base href="https://polygit.org/polymer+1.5.0/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="iron-list/iron-list.html">
<link rel="import" href="iron-scroll-threshold/iron-scroll-threshold.html">
<link rel="import" href="paper-progress/paper-progress.html">
</head>
<body>
<x-foo></x-foo>
<dom-module id="x-foo">
<template>
<style>
iron-list {
height: 400px;
}
</style>
<iron-scroll-threshold id="threshold"
lower-threshold="50"
on-lower-threshold="_loadMoreData"
lower-triggered="{{nearBottom}}">
<iron-list scroll-target="threshold" items="[[items]]">
<template>
<div>[[index]]: [[item]]</div>
</template>
</iron-list>
</iron-scroll-threshold>
<button on-tap="handleTap">Load More</button>
<template is="dom-if" if="[[nearBottom]]">
<paper-progress indeterminate></paper-progress>
</template>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo',
properties: {
items: {
type: Array,
value: function() { return []; }
}
},
handleTap: function() {
_loadMoreData();
},
_loadMoreData: function() {
console.log('loading 100 more...');
// simulate network delay
this.async(function() {
for (let i = 0; i < 50; i++) {
this.push('items', Math.random());
}
this.$.threshold.clearTriggers();
}, 500);
}
});
});
</script>
</dom-module>
</body>
这是我要测试的代码
您缺少this
:
handleTap: function() {
this._loadMoreData();
}
相关文章:
- 镀铬延长件内部的聚合物纸按钮不起作用
- 除“;改变“;用于聚合物单选按钮
- 在JavaScript点击事件中创建的聚合物纸按钮未启动
- 聚合物:纸张操作对话框打开时,纸张菜单按钮不会关闭
- 按下一组聚合物纸张切换按钮之一时触发事件
- 尝试使用聚合物纸张切换按钮
- 聚合物纸张切换按钮
- 如何将纸张切换按钮绑定到聚合物中的布尔值
- 在聚合物1.0中,使用纸质按钮时无法访问数据属性
- 聚合物:在纸张按钮按下“ok”后,在纸张对话框内获得纸张输入的值
- 点击聚合物v1.0输入验证按钮
- 聚合物1.0如何获得点击纸张按钮的id
- 如何从一组颜色动态地改变聚合物1.0纸按钮的颜色
- 加载更多的内容上的按钮点击在聚合物
- 聚合物纸图标按钮不开火点击
- 聚合物1.0纸单选按钮不工作在流星
- 聚合物中凸起的纸张按钮上不显示波纹效果和阴影
- 单击事件未在聚合物纸图标按钮中触发
- 聚合物在点击时更改纸质图标按钮中的图标
- 聚合物 v1.2.4 - 在背景元素的情况下,能够按 Tab/Shift-Tab 键切换到背景按钮