提交 41fc6e53 编写于 作者: W wanganxp

完善scroll-view细节

上级 690b6ed5
...@@ -34,10 +34,6 @@ ...@@ -34,10 +34,6 @@
<text>是否有反弹效果</text> <text>是否有反弹效果</text>
<switch :checked="bounces" @change="bounces=!bounces"></switch> <switch :checked="bounces" @change="bounces=!bounces"></switch>
</view> </view>
<view class="uni-option">
<text>是否开启双击标题栏返回顶部</text>
<switch :checked="enableBackToTop" @change="enableBackToTop=!enableBackToTop"></switch>
</view>
<view class="uni-option"> <view class="uni-option">
<text>是否开启滚动时使用动画过渡</text> <text>是否开启滚动时使用动画过渡</text>
<switch :checked="scrollWithAnimation" @change="scrollWithAnimation=!scrollWithAnimation"></switch> <switch :checked="scrollWithAnimation" @change="scrollWithAnimation=!scrollWithAnimation"></switch>
...@@ -206,7 +202,7 @@ ...@@ -206,7 +202,7 @@
} }
.uni-slider { .uni-slider {
height: 100rpx; height: 60px;
padding: 30rpx; padding: 30rpx;
justify-content: center; justify-content: center;
} }
......
<template> <template>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view style="flex: 1"> <scroll-view style="flex: 1">
<!-- #endif --> <!-- #endif -->
<view> <view>
<page-head title="scroll-view,区域滚动视图"></page-head> <page-head title="scroll-view,区域滚动视图"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-title uni-common-mt"> <view class="uni-title uni-common-mt">
<text class="uni-title-text">Vertical Scroll</text> <text class="uni-title-text">Vertical Scroll</text>
<text class="uni-subtitle-text">纵向滚动</text> <text class="uni-subtitle-text">纵向滚动</text>
</view> </view>
<view> <view>
<scroll-view <scroll-view :scrollTop="scrollTop" :scrollY="true" class="scroll-Y" scroll-with-animation="true"
:scrollTop="scrollTop" @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
:scrollY="true" <view id="demo1" class="scroll-view-item uni-bg-red"><text class="text">A</text></view>
class="scroll-Y" <view id="demo2" class="scroll-view-item uni-bg-green"><text class="text">B</text></view>
scroll-with-animation="true" <view id="demo3" class="scroll-view-item uni-bg-blue"><text class="text">C</text></view>
@scrolltoupper="upper" </scroll-view>
@scrolltolower="lower" </view>
@scroll="scroll" <view @tap="goTop" class="uni-center uni-common-mt">
> <text class="uni-link">点击这里返回顶部</text>
<view id="demo1" class="scroll-view-item uni-bg-red" </view>
><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"> <view class="uni-title uni-common-mt">
<text class="uni-subtitle-text">下拉刷新</text> <text class="uni-title-text">Horizontal Scroll</text>
</view> <text class="uni-subtitle-text">横向滚动</text>
<button </view>
type="primary" <view>
class="button default-button" <scroll-view class="scroll-view_H" :scrollX="true" @scroll="scroll" :scrollLeft="120">
@click="gotoRefresher" <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>
</button> </scroll-view>
</view>
<view class="uni-title uni-common-mt"> <navigator url="/pages/component/scroll-view/scroll-view-props">
<text class="uni-title-text">Horizontal Scroll</text> <button type="primary" class="button default-button">
<text class="uni-subtitle-text">横向滚动</text> 非下拉刷新的属性示例
</view> </button>
<view> </navigator>
<scroll-view <view class="uni-common-pb"></view>
class="scroll-view_H" <navigator url="/pages/component/scroll-view/scroll-view-refresher-props">
:scrollX="true" <button type="primary" class="button default-button">
@scroll="scroll" 下拉刷新的属性示例
:scrollLeft="120" </button>
> </navigator>
<view id="demo1" class="scroll-view-item_H uni-bg-red" <view class="uni-common-pb"></view>
><text class="text">A</text></view <navigator url="/pages/component/scroll-view/scroll-view-refresher">
> <button type="primary" class="button default-button"> 默认下拉刷新示例 </button>
<view id="demo2" class="scroll-view-item_H uni-bg-green" </navigator>
><text class="text">B</text></view <view class="uni-common-pb"></view>
> <navigator url="/pages/component/scroll-view/scroll-view-custom-refresher-props">
<view id="demo3" class="scroll-view-item_H uni-bg-blue" <button type="primary" class="button default-button">
><text class="text">C</text></view 自定义下拉刷新示例
> </button>
</scroll-view> </navigator>
</view> <view class="uni-common-pb"></view>
</view>
<button </view>
type="primary" <!-- #ifdef APP -->
class="button default-button" </scroll-view>
@click="moreProps" <!-- #endif -->
>
非下拉刷新的属性示例
</button>
<view class="uni-common-pb"></view>
<button type="primary" class="button default-button" @click="jumpToRefresher">
下拉刷新的属性示例
</button>
<view class="uni-common-pb"></view>
<button type="primary" class="button default-button" @click="jumpToCustomRefresher">
自定义下拉刷新的属性示例
</button>
<view class="uni-common-pb"></view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template> </template>
<script lang="ts"> <script lang="ts">
import ScrollToLowerEvent from 'io.dcloud.uniapp.runtime.ScrollToLowerEvent' import ScrollToLowerEvent from 'io.dcloud.uniapp.runtime.ScrollToLowerEvent'
import ScrollToUpperEvent from 'io.dcloud.uniapp.runtime.ScrollToUpperEvent' import ScrollToUpperEvent from 'io.dcloud.uniapp.runtime.ScrollToUpperEvent'
export default { export default {
data() { data() {
return { return {
scrollTop: 0, scrollTop: 0,
oldScrollTop: 0, oldScrollTop: 0,
} }
}, },
methods: { methods: {
upper: function (e: ScrollToUpperEvent) { upper: function (e : ScrollToUpperEvent) {
console.log(e) console.log(e)
}, },
lower: function (e: ScrollToLowerEvent) { lower: function (e : ScrollToLowerEvent) {
console.log(e) console.log(e)
}, },
scroll: function (e: ScrollEvent) { scroll: function (e : ScrollEvent) {
this.oldScrollTop = e.detail.scrollTop this.oldScrollTop = e.detail.scrollTop
}, },
goTop: function () { goTop: function () {
// 解决view层不同步的问题 // 解决view层不同步的问题
this.scrollTop = this.oldScrollTop this.scrollTop = this.oldScrollTop
this.$nextTick(function () { this.$nextTick(function () {
this.scrollTop = 0 this.scrollTop = 0
}) })
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '纵向滚动 scrollTop 值已被修改为 0', title: '纵向滚动 scrollTop 值已被修改为 0',
}) })
}, }
gotoRefresher: function () { },
uni.navigateTo({
url: '/pages/component/scroll-view/scroll-view-refresher',
})
},
moreProps(){
uni.navigateTo({
url: '/pages/component/scroll-view/scroll-view-props',
})
},
jumpToRefresher() {
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> </script>
<style> <style>
.scroll-Y { .scroll-Y {
height: 300rpx; height: 300rpx;
} }
.scroll-view_H { .scroll-view_H {
width: 100%; width: 100%;
flex-direction: row; flex-direction: row;
} }
.scroll-view-item { .scroll-view-item {
height: 300rpx; height: 300rpx;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.scroll-view-item_H { .scroll-view-item_H {
width: 690rpx; width: 690rpx;
height: 300rpx; height: 300rpx;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.text { .text {
font-size: 36rpx; font-size: 36rpx;
color: #ffffff; color: #ffffff;
} }
.button {
margin-top: 30rpx; .button {
} margin-top: 30rpx;
</style> }
</style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册