Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
b042e870
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5994
Star
90
Fork
162
代码
文件
提交
分支
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看板
提交
b042e870
编写于
8月 19, 2023
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 增加自定义下拉刷新属性例子。
上级
3378f686
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
106 addition
and
6 deletion
+106
-6
pages.json
pages.json
+10
-1
pages/component/scroll-view/scroll-view-custom-refresher-props.uvue
...onent/scroll-view/scroll-view-custom-refresher-props.uvue
+75
-0
pages/component/scroll-view/scroll-view.uvue
pages/component/scroll-view/scroll-view.uvue
+12
-3
pages/template/custom-refresher/custom-refresher.uvue
pages/template/custom-refresher/custom-refresher.uvue
+8
-1
pages/template/custom-refresher/refresh-box/refresh-box.uvue
pages/template/custom-refresher/refresh-box/refresh-box.uvue
+1
-1
未找到文件。
pages.json
浏览文件 @
b042e870
...
...
@@ -788,7 +788,16 @@
"enablePullDownRefresh"
:
false
}
}
],
,{
"path"
:
"pages/component/scroll-view/scroll-view-custom-refresher-props"
,
"style"
:
{
"navigationBarTitleText"
:
"自定义下拉刷新的scroll-view属性示例"
,
"enablePullDownRefresh"
:
false
}
}
],
"globalStyle"
:
{
"pageOrientation"
:
"portrait"
,
"navigationBarTitleText"
:
"Hello uniapp x"
,
...
...
pages/component/scroll-view/scroll-view-custom-refresher-props.uvue
0 → 100644
浏览文件 @
b042e870
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1" :refresher-enabled="true" :refresher-triggered="refresherTriggered"
refresher-default-style="none" @refresherpulling="onRefresherpulling" @refresherrefresh="onRefresherrefresh">
<!-- #endif -->
<scroll-view style="margin: 50rpx;">
<view v-for="i in 20" class="content-item">
<text class="text">item-{{i}}</text>
</view>
</scroll-view>
<refresh-box slot="refresher" :state="state"></refresh-box>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import RefresherEvent from 'io.dcloud.uniapp.runtime.RefresherEvent';
import refreshBox from '../../template/custom-refresher/refresh-box/refresh-box.uvue';
export default {
components: { refreshBox },
data() {
return {
refresherTriggered: false,
pullingDistance: 0,
resetting: false
}
},
computed: {
state() : number {
if (this.resetting) {
return 3;
}
if (this.refresherTriggered) {
return 2
}
if (this.pullingDistance > 45) {
return 1
} else {
return 0;
}
}
},
methods: {
onRefresherpulling(e : RefresherEvent) {
this.pullingDistance = e.detail.dy;
if (this.pullingDistance.toDouble() == 0.0) {
this.resetting = false;
}
},
onRefresherrefresh() {
this.refresherTriggered = true
setTimeout(() => {
this.refresherTriggered = false
this.resetting = true;
}, 1500)
},
}
}
</script>
<style>
.content-item {
padding: 15px;
margin: 5px 0;
background-color: #fff;
border-radius: 5px;
}
.text {
font-size: 14px;
color: #666;
line-height: 20px;
}
</style>
\ No newline at end of file
pages/component/scroll-view/scroll-view.uvue
浏览文件 @
b042e870
...
...
@@ -73,11 +73,15 @@
class="button default-button"
@click="moreProps"
>
非下拉刷新的
scroll-view
属性示例
非下拉刷新的属性示例
</button>
<view class="uni-common-pb"></view>
<button type="primary" class="button default-button" @click="jumpToRefresher">
下拉刷新的scroll-view属性示例
下拉刷新的属性示例
</button>
<view class="uni-common-pb"></view>
<button type="primary" class="button default-button" @click="jumpToCustomRefresher">
自定义下拉刷新的属性示例
</button>
<view class="uni-common-pb"></view>
</view>
...
...
@@ -132,7 +136,12 @@ export default {
uni.navigateTo({
url: '/pages/component/scroll-view/scroll-view-refresher-props',
})
},
},
jumpToCustomRefresher() {
uni.navigateTo({
url: '/pages/component/scroll-view/scroll-view-custom-refresher-props',
})
}
},
}
</script>
...
...
pages/template/custom-refresher/custom-refresher.uvue
浏览文件 @
b042e870
...
...
@@ -23,11 +23,15 @@
return {
refresherTriggered:false,
refresherThreshold:40,
pullingDistance:0
pullingDistance:0,
resetting: false
}
},
computed:{
state():number{
if (this.resetting) {
return 3;
}
if(this.refresherTriggered){
return 2
}
...
...
@@ -42,6 +46,9 @@
onRefresherpulling(e:RefresherEvent){
// console.log('onRefresherpulling',e.detail.dy)
this.pullingDistance = e.detail.dy
if (this.pullingDistance.toDouble() == 0.0) {
this.resetting = false;
}
},
onRefresherrefresh(){
this.refresherTriggered = true
...
...
pages/template/custom-refresher/refresh-box/refresh-box.uvue
浏览文件 @
b042e870
...
...
@@ -11,7 +11,7 @@
export default {
data() {
return {
text: ['继续下拉执行刷新', '释放立即刷新', '刷新中']
text: ['继续下拉执行刷新', '释放立即刷新', '刷新中'
, ""
]
}
},
props: {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录