Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
89eeb46e
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看板
提交
89eeb46e
编写于
9月 07, 2023
作者:
shutao-dc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update scroll-view.uvue
上级
36af2005
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
130 addition
and
130 deletion
+130
-130
pages/component/scroll-view/scroll-view.uvue
pages/component/scroll-view/scroll-view.uvue
+130
-130
未找到文件。
pages/component/scroll-view/scroll-view.uvue
浏览文件 @
89eeb46e
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head title="scroll-view,区域滚动视图"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title uni-common-mt">
<text class="uni-title-text">Vertical Scroll</text>
<text class="uni-subtitle-text">纵向滚动</text>
</view>
<view>
<scroll-view :scrollTop="scrollTop" :scrollY="true" class="scroll-Y" scroll-with-animation="true"
@scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
<view id="demo1" class="scroll-view-item uni-bg-red"><text class="text">A</text></view>
<view id="demo2" class="scroll-view-item uni-bg-green"><text class="text">B</text></view>
<view id="demo3" class="scroll-view-item uni-bg-blue"><text class="text">C</text></view>
</scroll-view>
</view>
<view @tap="goTop" class="uni-center uni-common-mt">
<text class="uni-link">点击这里返回顶部</text>
</view>
<view class="uni-title uni-common-mt">
<text class="uni-title-text">Horizontal Scroll</text>
<text class="uni-subtitle-text">横向滚动</text>
</view>
<view>
<scroll-view class="scroll-view_H" :scrollX="true" @scroll="scroll" :scrollLeft="120">
<view id="demo1" class="scroll-view-item_H uni-bg-red"><text class="text">A</text></view>
<view id="demo2" class="scroll-view-item_H uni-bg-green"><text class="text">B</text></view>
<view id="demo3" class="scroll-view-item_H uni-bg-blue"><text class="text">C</text></view>
</scroll-view>
</view>
<navigator url="/pages/component/scroll-view/scroll-view-props">
<button type="primary" class="button default-button">
非下拉刷新的属性示例
</button>
</navigator>
<view class="uni-common-pb"></view>
<navigator url="/pages/component/scroll-view/scroll-view-refresher-props">
<button type="primary" class="button default-button">
下拉刷新的属性示例
</button>
</navigator>
<view class="uni-common-pb"></view>
<navigator url="/pages/component/scroll-view/scroll-view-refresher">
<button type="primary" class="button default-button"> 默认下拉刷新示例 </button>
</navigator>
<view class="uni-common-pb"></view>
<navigator url="/pages/component/scroll-view/scroll-view-custom-refresher-props">
<button type="primary" class="button default-button">
自定义下拉刷新示例
</button>
</navigator>
<view class="uni-common-pb"></view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import ScrollToLowerEvent from 'io.dcloud.uniapp.runtime.ScrollToLowerEvent'
import ScrollToUpperEvent from 'io.dcloud.uniapp.runtime.ScrollToUpperEvent'
export default {
data() {
return {
scrollTop: 0,
oldScrollTop: 0,
}
},
methods: {
upper: function (e : ScrollToUpperEvent) {
console.log(e)
},
lower: function (e : ScrollToLowerEvent) {
console.log(e)
},
scroll: function (e : ScrollEvent) {
this.oldScrollTop = e.detail.scrollTop
},
goTop: function () {
// 解决view层不同步的问题
this.scrollTop = this.oldScrollTop
this.$nextTick(function () {
this.scrollTop = 0
})
uni.showToast({
icon: 'none',
title: '纵向滚动 scrollTop 值已被修改为 0',
})
}
},
}
</script>
<style>
.scroll-Y {
height: 300rpx;
}
.scroll-view_H {
width: 100%;
flex-direction: row;
}
.scroll-view-item {
height: 300rpx;
justify-content: center;
align-items: center;
}
.scroll-view-item_H {
width: 690rpx;
height: 300rpx;
justify-content: center;
align-items: center;
}
.text {
font-size: 36rpx;
color: #ffffff;
}
.button {
margin-top: 30rpx;
}
</style>
\ No newline at end of file
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head title="scroll-view,区域滚动视图"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title uni-common-mt">
<text class="uni-title-text">Vertical Scroll</text>
<text class="uni-subtitle-text">纵向滚动</text>
</view>
<view>
<scroll-view :scroll-top="scrollTop" :scroll-y="true" class="scroll-Y" scroll-with-animation="true"
@scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
<view id="demo1" class="scroll-view-item uni-bg-red"><text class="text">A</text></view>
<view id="demo2" class="scroll-view-item uni-bg-green"><text class="text">B</text></view>
<view id="demo3" class="scroll-view-item uni-bg-blue"><text class="text">C</text></view>
</scroll-view>
</view>
<view @tap="goTop" class="uni-center uni-common-mt">
<text class="uni-link">点击这里返回顶部</text>
</view>
<view class="uni-title uni-common-mt">
<text class="uni-title-text">Horizontal Scroll</text>
<text class="uni-subtitle-text">横向滚动</text>
</view>
<view>
<scroll-view class="scroll-view_H" :scroll-x="true" @scroll="scroll" :scroll-left="120">
<view id="demo1" class="scroll-view-item_H uni-bg-red"><text class="text">A</text></view>
<view id="demo2" class="scroll-view-item_H uni-bg-green"><text class="text">B</text></view>
<view id="demo3" class="scroll-view-item_H uni-bg-blue"><text class="text">C</text></view>
</scroll-view>
</view>
<navigator url="/pages/component/scroll-view/scroll-view-props">
<button type="primary" class="button default-button">
非下拉刷新的属性示例
</button>
</navigator>
<view class="uni-common-pb"></view>
<navigator url="/pages/component/scroll-view/scroll-view-refresher-props">
<button type="primary" class="button default-button">
下拉刷新的属性示例
</button>
</navigator>
<view class="uni-common-pb"></view>
<navigator url="/pages/component/scroll-view/scroll-view-refresher">
<button type="primary" class="button default-button"> 默认下拉刷新示例 </button>
</navigator>
<view class="uni-common-pb"></view>
<navigator url="/pages/component/scroll-view/scroll-view-custom-refresher-props">
<button type="primary" class="button default-button">
自定义下拉刷新示例
</button>
</navigator>
<view class="uni-common-pb"></view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import ScrollToLowerEvent from 'io.dcloud.uniapp.runtime.ScrollToLowerEvent'
import ScrollToUpperEvent from 'io.dcloud.uniapp.runtime.ScrollToUpperEvent'
export default {
data() {
return {
scrollTop: 0,
oldScrollTop: 0,
}
},
methods: {
upper: function (e : ScrollToUpperEvent) {
console.log(e)
},
lower: function (e : ScrollToLowerEvent) {
console.log(e)
},
scroll: function (e : ScrollEvent) {
this.oldScrollTop = e.detail.scrollTop
},
goTop: function () {
// 解决view层不同步的问题
this.scrollTop = this.oldScrollTop
this.$nextTick(function () {
this.scrollTop = 0
})
uni.showToast({
icon: 'none',
title: '纵向滚动 scrollTop 值已被修改为 0',
})
}
},
}
</script>
<style>
.scroll-Y {
height: 300rpx;
}
.scroll-view_H {
width: 100%;
flex-direction: row;
}
.scroll-view-item {
height: 300rpx;
justify-content: center;
align-items: center;
}
.scroll-view-item_H {
width: 690rpx;
height: 300rpx;
justify-content: center;
align-items: center;
}
.text {
font-size: 36rpx;
color: #ffffff;
}
.button {
margin-top: 30rpx;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录