Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
bf086080
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
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看板
提交
bf086080
编写于
9月 07, 2023
作者:
shutao-dc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update scroll-view-refresher-props.uvue
上级
b594a3c6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
172 addition
and
167 deletion
+172
-167
pages/component/scroll-view/scroll-view-refresher-props.uvue
pages/component/scroll-view/scroll-view-refresher-props.uvue
+172
-167
未找到文件。
pages/component/scroll-view/scroll-view-refresher-props.uvue
浏览文件 @
bf086080
<template>
<template>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<view style="flex:1;">
<view style="flex:1;">
<!-- #endif -->
<!-- #endif -->
<page-head title="下拉刷新的scroll-view属性示例"></page-head>
<page-head title="下拉刷新的scroll-view属性示例"></page-head>
<view class="uni-margin-wrap">
<view class="uni-margin-wrap">
<scroll-view :refresher-enabled="refresherEnabled" :refresher-threshold="refresherThreshold"
<scroll-view :refresher-enabled="refresherEnabled" :refresher-threshold="refresherThreshold"
:refresher-default-style="refresherDefaultStyle" :refresher-background="refresherBackground"
:refresher-default-style="refresherDefaultStyle" :refresher-background="refresherBackground"
:refresher-triggered="refresherTriggered" @refresherpulling="refresherpulling"
:refresher-triggered="refresherTriggered" @refresherpulling="refresherpulling"
@refresherrefresh="refresherrefresh" @refresherrestore="refresherrestore"
@refresherrefresh="refresherrefresh" @refresherrestore="refresherrestore"
@refresherabort="refresherabort">
@refresherabort="refresherabort">
<view class="item" :id="item.id" v-for="(item,_) in items">
<view class="item" :id="item.id" v-for="(item,_) in items">
<text class="uni-text">{{item.label}}</text>
<text class="uni-text">{{item.label}}</text>
</view>
</view>
</scroll-view>
</scroll-view>
</view>
</view>
<scroll-view class="uni-list" showScrollbar="true">
<scroll-view class="uni-list" showScrollbar="true">
<view class="uni-common-pb"></view>
<view class="uni-common-pb"></view>
<text style="font-size: 12;text-align: center;color: red; ">**下拉刷新的属性设置需要先打开下拉刷新开关**</text>
<text style="font-size: 12;text-align: center;color: red; ">**下拉刷新的属性设置需要先打开下拉刷新开关**</text>
<view class="uni-common-pb"></view>
<view class="uni-common-pb"></view>
<view class="uni-option">
<view class="uni-option">
<text>是否开启下拉刷新</text>
<text>是否开启下拉刷新</text>
<switch :checked="refresherEnabled" @change="handleTrunOnRefresher"></switch>
<switch :checked="refresherEnabled" @change="handleTrunOnRefresher"></switch>
</view>
</view>
<view class="uni-option">
<view class="uni-option">
<text>设置下拉刷新状态</text>
<text>设置下拉刷新状态</text>
<switch :disabled="!refresherEnabled" :checked="refresherTriggered"
<switch :disabled="!refresherEnabled" :checked="refresherTriggered"
@change="refresherTriggered=!refresherTriggered"></switch>
@change="refresherTriggered=!refresherTriggered"></switch>
</view>
</view>
<view class="uni-option">
<view class="uni-option">
<text>设置下拉刷新阈值</text>
<text>设置下拉刷新阈值</text>
<input style="width: 100rpx;border-width: 2rpx;text-align: center; " :disabled="!refresherEnabled"
<input style="width: 100rpx;border-width: 2rpx;text-align: center; " :disabled="!refresherEnabled"
:value="refresherThreshold" type="number" @input="handleRefresherThresholdInput" />
:value="refresherThreshold" type="number" @input="handleRefresherThresholdInput" />
</view>
</view>
<view class="uni-option">
<view class="uni-option">
<text>设置下拉刷新区域背景颜色</text>
<text>设置下拉刷新区域背景颜色</text>
<input style="width: 200rpx;border-width: 2rpx;text-align: center; " :disabled="!refresherEnabled"
<input style="width: 200rpx;border-width: 2rpx;text-align: center; " :disabled="!refresherEnabled"
:value="refresherBackground" @input="handleRefresherBackground" />
:value="refresherBackground" @input="handleRefresherBackground" />
</view>
</view>
<view style="height: 200rpx;padding: 20rpx; ">
<view style="height: 200rpx;padding: 20rpx; ">
<text>设置下拉刷新默认样式</text>
<text>设置下拉刷新默认样式</text>
<view class="uni-common-pb"></view>
<view class="uni-common-pb"></view>
<view style="flex-direction: row;">
<view style="flex-direction: row;">
<button style="padding: 5rpx; margin-right: 10rpx;" type="primary" size="mini"
<button style="padding: 5rpx; margin-right: 10rpx;" type="primary" size="mini"
@click="refresherDefaultStyle = `none`">none</button>
@click="refresherDefaultStyle = `none`">none</button>
<button style="padding: 5rpx; margin-right: 10rpx; " type="primary" size="mini"
<button style="padding: 5rpx; margin-right: 10rpx; " type="primary" size="mini"
@click="refresherDefaultStyle = `black`">black</button>
@click="refresherDefaultStyle = `black`">black</button>
<button style="padding: 5rpx;" type="primary" size="mini"
<button style="padding: 5rpx;" type="primary" size="mini"
@click="refresherDefaultStyle = `white`">white</button>
@click="refresherDefaultStyle = `white`">white</button>
</view>
</view>
</view>
</view>
<!-- //todo 还有自定义下拉刷新样式的例子 -->
<!-- //todo 还有自定义下拉刷新样式的例子 -->
<view class="uni-common-pb"></view>
<view class="uni-common-pb"></view>
</scroll-view>
</scroll-view>
</view>
</view>
</template>
</template>
<script>
<script>
type Item = {
type Item = {
id : string,
id : string,
label : string,
label : string,
}
}
export default {
export default {
data() {
data() {
return {
return {
items: [] as Item[],
items: [] as Item[],
refresherEnabled: false,
refresherEnabled: false,
refresherTriggered: false,
refresherTriggered: false,
refresherThreshold: 45,
refresherThreshold: 45,
refresherDefaultStyle: "white",
refresherDefaultStyle: "white",
refresherBackground: "transparent",
refresherBackground: "transparent",
}
}
},
},
onLoad() {
onLoad() {
for (let i = 0; i < 10; i++) {
for (let i = 0; i < 10; i++) {
const item = {
const item = {
id: "item" + i,
id: "item" + i,
label: "item" + i,
label: "item" + i,
} as Item;
} as Item;
this.items.push(item);
this.items.push(item);
}
}
},
},
methods: {
methods: {
handleTrunOnRefresher() {
handleTrunOnRefresher() {
this.refresherTriggered = false;
this.refresherTriggered = false;
//不能同时关闭下拉状态和关闭下拉刷新。
//不能同时关闭下拉状态和关闭下拉刷新。
setTimeout(() => {
setTimeout(() => {
this.refresherEnabled = !this.refresherEnabled;
this.refresherEnabled = !this.refresherEnabled;
}, 0)
}, 0)
},
},
handleRefresherThresholdInput(e : InputEvent) {
handleRefresherThresholdInput(e : InputEvent) {
const value = e.detail.value;
const value = e.detail.value;
if (value == "") {
if (value == "") {
this.refresherThreshold = 45;
this.refresherThreshold = 45;
} else {
} else {
this.refresherThreshold = parseInt(e.detail.value);
this.refresherThreshold = parseInt(e.detail.value);
}
}
},
},
handleRefresherBackground(e : InputEvent) {
handleRefresherBackground(e : InputEvent) {
const value = e.detail.value;
const value = e.detail.value;
this.refresherBackground = value;
this.refresherBackground = value;
},
},
//响应事件
//响应事件
refresherpulling() {
refresherpulling() {
console.log("下拉刷新控件被下拉");
console.log("下拉刷新控件被下拉");
},
},
refresherrefresh() {
refresherrefresh() {
console.log("下拉刷新被触发");
console.log("下拉刷新被触发");
},
this.refresherTriggered = true;
refresherrestore() {
//不能同时关闭下拉状态和关闭下拉刷新。
console.log("下拉刷新被复位");
setTimeout(() => {
},
this.refresherTriggered = false;
refresherabort() {
}, 1500)
console.log("下拉刷新被中止");
},
}
refresherrestore() {
}
console.log("下拉刷新被复位");
}
},
</script>
refresherabort() {
console.log("下拉刷新被中止");
<style>
}
.uni-margin-wrap {
}
height: 400rpx;
}
margin-left: 50rpx;
</script>
margin-right: 50rpx;
}
<style>
.uni-margin-wrap {
.item {
height: 400rpx;
justify-content: center;
margin-left: 50rpx;
align-items: center;
margin-right: 50rpx;
height: 400rpx;
}
width: 100%;
background-color: azure;
.item {
border-width: 2rpx;
justify-content: center;
border-color: chocolate;
align-items: center;
}
height: 400rpx;
width: 100%;
.uni-text {
background-color: azure;
color: black;
border-width: 2rpx;
font-size: 50px;
border-color: chocolate;
}
}
.uni-list {
.uni-text {
flex: 1;
color: black;
margin: 50rpx 50rpx 0rpx 50rpx;
font-size: 50px;
}
}
.uni-option {
.uni-list {
height: 100rpx;
flex: 1;
flex-direction: row;
margin: 50rpx 50rpx 0rpx 50rpx;
justify-content: space-between;
}
align-items: center;
padding: 20rpx;
.uni-option {
}
height: 100rpx;
flex-direction: row;
.picker-view {
justify-content: space-between;
width: 100%;
align-items: center;
height: 320px;
padding: 20rpx;
margin-top: 10px;
}
}
</style>
.picker-view {
\ No newline at end of file
width: 100%;
height: 320px;
margin-top: 10px;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录