scroll-view-refresher.uvue 1.6 KB
Newer Older
S
shutao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
<template>
	<view class="container">
		<page-head title="scroll-view 下拉刷新"></page-head>
		<scroll-view class="scroll" refresher-enabled = true @refresherrefresh="onRefresherrefresh" :refresher-triggered = "refresherTriggered">
			<view v-for="key in scrollData" :key="key">
				<view class="scroll-item">
					<text class="scroll-item-title">{{key}}</text>
				</view>
			</view>
		</scroll-view>
	</view>
</template>
<script>
	export default {

		data() {
			return {
				scrollData: [] as Array <string>,
				refresherTriggered: false 
			};
		},
		onLoad() {
			let lists: Array < string > = []
			for (let i = 0; i < 20; i++) {
				lists.push("item---"+i)
			}
			this.scrollData = lists
		},

		methods: {
			onRefresherrefresh(e: RefresherEvent) {
				console.log("onRefresherrefresh--------------下拉刷新触发")
				this.refresherTriggered = true
				setTimeout(function(){
					this.refresherTriggered = false
				}, 1500)
				
			}
		}
	};
</script>

<style>
	.container{
		display: flex;
		flex-direction: column;
		border:dashed;
		flex: 1;
	}
	
	.scroll {
		background-color: #eee;
		position: relative;
		width: 100%;
		flex: 1;
		display: flex;
		flex-direction: column;
		border-color: red;
	}
	
	.scroll-item {
	    margin-left: 12rpx;
	    margin-right: 12rpx;
	    margin-top: 12rpx;
		background-color: #fff;
	    border-radius: 8rpx;
	}
	
	.scroll-item-title {
	    width:100%;
	    height: 120rpx;
	    line-height: 120rpx;
	    text-align: center;
	    color: #555;
	}
	
	

</style>