Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
ef4b31e0
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6001
Star
91
Fork
163
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ef4b31e0
编写于
5月 24, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(pulldown refresh): 优化下拉刷新示例并补充测试
上级
354384a3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
114 addition
and
75 deletion
+114
-75
pages/API/pull-down-refresh/pull-down-refresh.test.js
pages/API/pull-down-refresh/pull-down-refresh.test.js
+33
-0
pages/API/pull-down-refresh/pull-down-refresh.uvue
pages/API/pull-down-refresh/pull-down-refresh.uvue
+81
-75
未找到文件。
pages/API/pull-down-refresh/pull-down-refresh.test.js
0 → 100644
浏览文件 @
ef4b31e0
const
PAGE_PATH
=
"
/pages/API/pull-down-refresh/pull-down-refresh
"
describe
(
"
payment
"
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
===
'
true
'
)
{
it
(
'
web || app-webview
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
it
(
"
trigger pulldown refresh by swipe
"
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
waitFor
(
4000
)
await
page
.
setData
({
pulldownRefreshTriggered
:
false
})
await
program
.
swipe
({
startPoint
:
{
x
:
100
,
y
:
400
},
endPoint
:
{
x
:
100
,
y
:
800
},
duration
:
1000
})
await
page
.
waitFor
(
1500
)
expect
(
await
page
.
data
(
'
pulldownRefreshTriggered
'
)).
toBe
(
true
)
});
});
pages/API/pull-down-refresh/pull-down-refresh.uvue
浏览文件 @
ef4b31e0
<template>
<template>
<scroll-view style="flex: 1;">
<!-- #ifdef APP -->
<!-- 实际开发中,长列表应该使用list-view -->
<scroll-view style="flex: 1;">
<view class="uni-padding-wrap uni-common-mt">
<!-- #endif -->
<text class="text" v-for="(num,index) in data" :key="index">list - {{num}}</text>
<!-- 实际开发中,长列表应该使用list-view -->
<view v-if="showLoadMore">{{loadMoreText}}</view>
<view class="uni-padding-wrap uni-common-mt">
</view>
<text class="text" v-for="(num,index) in data" :key="index">list - {{num}}</text>
</scroll-view>
<view v-if="showLoadMore">{{loadMoreText}}</view>
</template>
</view>
<script lang="uts">
<!-- #ifdef APP -->
export default {
</scroll-view>
data() {
<!-- #endif -->
return {
</template>
data: [] as Array<number>,
<script lang="uts">
loadMoreText: "加载中...",
export default {
showLoadMore: false,
data() {
max: 0
return {
}
data: [] as Array<number>,
},
loadMoreText: "加载中...",
onReady() {
showLoadMore: false,
uni.startPullDownRefresh();
max: 0,
this.initData();
pulldownRefreshTriggered: false
},
}
onReachBottom() {
},
console.log("onReachBottom");
onReady() {
if (this.max > 40) {
uni.startPullDownRefresh();
this.loadMoreText = "没有更多数据了!"
this.initData();
return;
},
}
onReachBottom() {
this.showLoadMore = true;
console.log("onReachBottom");
setTimeout(() => {
if (this.max > 40) {
this.setListData();
this.loadMoreText = "没有更多数据了!"
}, 300);
return;
},
}
onPullDownRefresh() {
this.showLoadMore = true;
console.log('onPullDownRefresh');
setTimeout(() => {
this.initData();
this.setListData();
},
}, 300);
methods: {
},
initData(){
onPullDownRefresh() {
setTimeout(() => {
console.log('onPullDownRefresh');
this.max = 0;
this.pulldownRefreshTriggered = true
this.data = [];
this.initData();
let data:Array<number> = [];
},
this.max += 20;
methods: {
for (let i:number = this.max - 19; i < this.max + 1; i++) {
initData() {
data.push(i)
setTimeout(() => {
}
this.max = 0;
this.data = this.data.concat(data);
this.data = [];
uni.stopPullDownRefresh();
let data : Array<number> = [];
}, 1000);
this.max += 20;
},
for (let i : number = this.max - 19; i < this.max + 1; i++) {
setListData() {
data.push(i)
let data:Array<number> = [];
}
this.max += 10;
this.data = this.data.concat(data);
for (let i:number = this.max - 9; i < this.max + 1; i++) {
uni.stopPullDownRefresh();
data.push(i)
}, 1000);
}
},
this.data = this.data.concat(data);
setListData() {
}
let data : Array<number> = [];
}
this.max += 10;
}
for (let i : number = this.max - 9; i < this.max + 1; i++) {
</script>
data.push(i)
}
<style>
this.data = this.data.concat(data);
.text {
}
margin: 6px 0;
}
width:100%;
}
background-color: #fff;
</script>
height: 52px;
line-height: 52px;
<style>
text-align: center;
.text {
color: #555;
margin: 6px 0;
border-radius: 4px;
width: 100%;
}
background-color: #fff;
height: 52px;
line-height: 52px;
text-align: center;
color: #555;
border-radius: 4px;
}
</style>
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录