提交 662f9ca6 编写于 作者: DCloud-yyl's avatar DCloud-yyl

优化自定义下拉刷新页面组件层级

上级 c1d3e9c2
...@@ -5,10 +5,8 @@ ...@@ -5,10 +5,8 @@
@refresherrefresh="onRefresherrefresh" @refresherrefresh="onRefresherrefresh"
:refresher-threshold="refresherThreshold" :refresher-threshold="refresherThreshold"
> >
<view class="content"> <view v-for="i in 20" class="content-item">
<view v-for="i in 20" class="content-item"> <text class="text">item-{{i}}</text>
<text class="text">item-{{i}}</text>
</view>
</view> </view>
<refresh-box slot="refresher" :state="state" :pullingDistance="pullingDistance"></refresh-box> <refresh-box slot="refresher" :state="state" :pullingDistance="pullingDistance"></refresh-box>
</scroll-view> </scroll-view>
...@@ -23,14 +21,14 @@ ...@@ -23,14 +21,14 @@
refresherTriggered:false, refresherTriggered:false,
refresherThreshold:40, refresherThreshold:40,
pullingDistance:0, pullingDistance:0,
resetting: false resetting: false
} }
}, },
computed:{ computed:{
state():number{ state():number{
if (this.resetting) { if (this.resetting) {
return 3; return 3;
} }
if(this.refresherTriggered){ if(this.refresherTriggered){
return 2 return 2
} }
...@@ -45,9 +43,9 @@ ...@@ -45,9 +43,9 @@
onRefresherpulling(e:RefresherEvent){ onRefresherpulling(e:RefresherEvent){
// console.log('onRefresherpulling',e.detail.dy) // console.log('onRefresherpulling',e.detail.dy)
this.pullingDistance = e.detail.dy this.pullingDistance = e.detail.dy
if (this.pullingDistance.toDouble() == 0.0) { if (this.pullingDistance.toDouble() == 0.0) {
this.resetting = false; this.resetting = false;
} }
}, },
onRefresherrefresh(){ onRefresherrefresh(){
this.refresherTriggered = true this.refresherTriggered = true
...@@ -66,26 +64,23 @@ ...@@ -66,26 +64,23 @@
</script> </script>
<style> <style>
.scroll-view { .scroll-view {
flex: 1; flex: 1;
background-color: #f5f5f5; padding: 5px 15px;
} background-color: #f5f5f5;
}
.content {
padding: 5px 15px;
}
.content-item { .content-item {
padding: 15px; padding: 15px;
margin: 5px 0; margin: 5px 0;
background-color: #fff; background-color: #fff;
border-radius: 5px; border-radius: 5px;
} }
.text { .text {
font-size: 14px; font-size: 14px;
color: #666; color: #666;
line-height: 20px; line-height: 20px;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册