list.uvue 1.7 KB
Newer Older
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
1 2 3 4
<template>
	<view style="height: 100%;width: 100%;">
		<page-head :title="title"></page-head>
		<view class="container">
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
5
			<list class="uni-list-inner" :refresher-enabled="true" @refresherrefresh="onRefresherrefresh"
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
6
				:refresher-triggered="refresherTriggered">
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
7
				<cell v-for="(item, index) in dataList" :key="item.id">
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
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
					<view class="list-item">
						<text class="list-item-title" :value="item.name"></text>
					</view>
				</cell>
			</list>
		</view>
	</view>
</template>
<script lang="ts">
	import RefresherEvent from 'io.dcloud.uniapp.runtime.RefresherEvent';
	type Item = {
		id : string,
		name : string
	}
	export default {
		data() {
			return {
				title: 'list',
				refresherTriggered: false,
				dataList: [] as Item[],
			}
		},
		onLoad() {
			for (var i = 0; i < 25; i++) {
				const item : Item = { id: i + "", name: "item " + i }
				this.dataList.push(item)
			}
		},
		methods: {
			onRefresherrefresh(e : RefresherEvent) {
				this.refresherTriggered = true
				setTimeout(function () {
					this.refresherTriggered = false
				}, 1000)
			}
		}
	}
</script>

<style>
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
48
	.uni-list-inner {
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
		background-color: #eee;
		position: relative;
		width: 100%;
		flex: 1;
		display: flex;
		flex-direction: column;
		border-color: red;
	}

	.container {
		display: flex;
		flex-direction: column;
		border: dashed;
		height: 100%;
		width: 100%;
	}

	.list-item {
		margin-left: 12px;
		margin-right: 12px;
		margin-top: 12px;
		padding: 20px;
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
71
		border-radius: 5px;
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
72 73 74 75 76 77 78 79 80 81
		background-color: #fff;
	}

	.list-item-title {
		font-size: 30px;
		font-weight: bold;
		color: #444;
		width: 100%;
	}
</style>