Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
4c380dff
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6072
Star
94
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4c380dff
编写于
6月 13, 2024
作者:
DCloud_iOS_XHY
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改 custom-refresher 示例 scroll-view 换成 list-view,并添加 sticky-header ,覆盖iOS的一个Bug测试例
上级
673ea56c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
74 deletion
+80
-74
pages/template/custom-refresher/custom-refresher.uvue
pages/template/custom-refresher/custom-refresher.uvue
+80
-74
未找到文件。
pages/template/custom-refresher/custom-refresher.uvue
浏览文件 @
4c380dff
<template>
<scroll-view class="scroll-view"
:refresher-enabled="true" :refresher-triggered="refresherTriggered" refresher-default-style="none"
@refresherpulling="onRefresherpulling"
@refresherrefresh="onRefresherrefresh"
@refresherrestore="onRefreshrestore"
:refresher-threshold="refresherThreshold"
refresher-max-drag-distance="200px"
>
<view v-for="i in 20" class="content-item">
<text class="text">item-{{i}}</text>
</view>
<refresh-box slot="refresher" :state="state" :pullingDistance="pullingDistance"></refresh-box>
</scroll-view>
</template>
<template>
<list-view class="list-view" :refresher-enabled="true" :refresher-triggered="refresherTriggered"
refresher-default-style="none" @refresherpulling="onRefresherpulling" @refresherrefresh="onRefresherrefresh"
@refresherrestore="onRefreshrestore" :refresher-threshold="refresherThreshold" refresher-max-drag-distance="200px">
<script>
import refreshBox from './refresh-box/refresh-box.uvue';
export default {
components:{refreshBox},
data() {
return {
refresherTriggered:false,
refresherThreshold:40,
pullingDistance:0,
resetting: false
}
},
computed:{
state():number{
if (this.resetting) {
return 3;
}
if(this.refresherTriggered){
return 2
}
if(this.pullingDistance > this.refresherThreshold){
return 1
}else{
return 0
}
}
},
methods: {
onRefresherpulling(e:RefresherEvent){
// console.log('onRefresherpulling',e.detail.dy)
this.pullingDistance = e.detail.dy
},
onRefresherrefresh(){
this.refresherTriggered = true
setTimeout(()=>{
this.refresherTriggered = false
this.resetting = true
},1500)
},
onRefreshrestore() {
this.pullingDistance = 0
this.resetting = false;
<sticky-header>
<view class="header">
<text>sticky header</text>
</view>
</sticky-header>
<list-item v-for="i in 20" class="content-item">
<text class="text">item-{{i}}</text>
</list-item>
<refresh-box slot="refresher" :state="state" :pullingDistance="pullingDistance"></refresh-box>
</list-view>
</template>
<script>
import refreshBox from './refresh-box/refresh-box.uvue';
export default {
components: { refreshBox },
data() {
return {
refresherTriggered: false,
refresherThreshold: 40,
pullingDistance: 0,
resetting: false
}
},
computed: {
state() : number {
if (this.resetting) {
return 3;
}
if (this.refresherTriggered) {
return 2
}
if (this.pullingDistance > this.refresherThreshold) {
return 1
} else {
return 0
}
}
},
methods: {
onRefresherpulling(e : RefresherEvent) {
// console.log('onRefresherpulling',e.detail.dy)
this.pullingDistance = e.detail.dy
},
onRefresherrefresh() {
this.refresherTriggered = true
setTimeout(() => {
this.refresherTriggered = false
this.resetting = true
}, 1500)
},
onRefreshrestore() {
this.pullingDistance = 0
this.resetting = false;
}
}
}
</script>
<style>
.scroll-view {
flex: 1;
padding: 5px 15px;
background-color: #f5f5f5;
}
.content-item {
padding: 15px;
margin: 5px 0;
background-color: #fff;
border-radius: 5px;
}
.list-view {
flex: 1;
background-color: #f5f5f5;
}
.text {
font-size: 14px;
color: #666;
line-height: 20px;
}
.header {
justify-content: center;
height: 50px;
background-color: #f5f5f5;
padding: 15px;
}
.content-item {
padding: 15px;
margin: 5px 0;
background-color: #fff;
border-radius: 5px;
}
.text {
font-size: 14px;
color: #666;
line-height: 20px;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录