refresh
下拉刷新容器。
权限列表
无
子组件
支持。
属性
除支持通用属性外,还支持如下属性:
样式
除支持通用样式外,还支持如下样式:
事件
仅支持如下事件:
|
||
|
方法
不支持通用方法。
示例
<!-- xxx.hml -->
<div class="container">
<refresh refreshing="{{fresh}}" onrefresh="refresh">
<list class="list" scrolleffect="no">
<list-item class="listitem" for="list">
<div class="content">
<text class="text">{{$item}}</text>
</div>
</list-item>
</list>
</refresh>
</div>
/* xxx.css */
.container {
flex-direction: column;
align-items: center;
width: 100%;
height: 100%;
}
.list {
width: 100%;
height: 100%;
}
.listitem {
width: 100%;
height: 150px;
}
.content {
width: 100%;
height: 100%;
flex-direction: column;
align-items: center;
justify-content: center;
}
.text {
font-size: 35px;
font-weight: bold;
}
// xxx.js
import prompt from '@system.prompt';
export default {
data: {
list:[],
fresh:false
},
onInit() {
this.list = [];
for (var i = 0; i <= 3; i++) {
var item = '列表元素' + i;
this.list.push(item);
}
},
refresh: function (e) {
prompt.showToast({
message: '刷新中...'
})
var that = this;
that.fresh = e.refreshing;
setTimeout(function () {
that.fresh = false;
var addItem = '更新元素';
that.list.unshift(addItem);
prompt.showToast({
message: '刷新完成!'
})
}, 2000)
}
}