sticky-header.uvue 2.5 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1
<template>
shutao-dc's avatar
shutao-dc 已提交
2
	<list-view :scroll-y="true" class="page" rebound="false" :scroll-top="scroll_top_input" :refresher-enabled="refresher_enabled_boolean"
shutao-dc's avatar
shutao-dc 已提交
3 4
	:refresher-triggered="refresher_triggered_boolean" @refresherrefresh="list_view_refresherrefresh">
    <list-item type = 1>
shutao-dc's avatar
shutao-dc 已提交
5
      <swiper indicator-dots="true" circular="true">
6
        <swiper-item  v-for="i in 3" :item-id="i">
shutao-dc's avatar
shutao-dc 已提交
7
          <image src="/static/shuijiao.jpg" style="height: 240px;"></image>
8
          <text style="position: absolute;">{{i}}</text>
shutao-dc's avatar
shutao-dc 已提交
9 10
        </swiper-item>
      </swiper>
shutao-dc's avatar
shutao-dc 已提交
11 12 13 14 15
    </list-item>
    <list-item class="content-item" type = 2>
			<text class="text">向上滑动页面,体验sticky-header吸顶效果。</text>
		</list-item>
		<sticky-header>
shutao-dc's avatar
shutao-dc 已提交
16
      <scroll-view style="background-color: #f5f5f5; flex-direction: row;" :scroll-x="true" :scroll-y="false" :show-scrollbar="false">
shutao-dc's avatar
shutao-dc 已提交
17 18
        <view class="flex-row" style="align-self: flex-start; flex-direction: row;">
          <text ref="swipertab" class="sift-item"
W
wanganxp 已提交
19
            v-for="(name,index) in sift_item" @click="clickTH(index)">
shutao-dc's avatar
shutao-dc 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
            {{name}}
          </text>
        </view>
      </scroll-view>
		</sticky-header>

		<list-item v-for="(item,index) in list_item" :key="index" class="content-item" type = 3>
			<text class="text">{{item}}</text>
		</list-item>
	</list-view>
</template>

<script>
	export default {
		data() {
			return {
shutao-dc's avatar
shutao-dc 已提交
36
				sift_item: ["排序", "筛选"],
shutao-dc's avatar
shutao-dc 已提交
37
				list_item: [] as Array<string>,
shutao-dc's avatar
shutao-dc 已提交
38
				refresher_enabled_boolean: true,
shutao-dc's avatar
shutao-dc 已提交
39 40
				refresher_triggered_boolean: false,
				scroll_top_input: 0
shutao-dc's avatar
shutao-dc 已提交
41 42 43 44 45
			}
		},
    onLoad() {
      let lists : Array<string> = []
      for (let i = 0; i < 40; i++) {
shutao-dc's avatar
shutao-dc 已提交
46
        lists.push("item---" + i)
shutao-dc's avatar
shutao-dc 已提交
47 48 49 50 51 52 53 54 55 56
      }
      this.list_item = lists
    },
		methods: {
			list_view_refresherrefresh() {
			  console.log("下拉刷新被触发 ")
			  this.refresher_triggered_boolean = true
			  setTimeout(function(){
			  	this.refresher_triggered_boolean = false
			  }, 1500)
shutao-dc's avatar
shutao-dc 已提交
57 58 59
			},
			confirm_scroll_top_input(value : number) {
			  this.scroll_top_input = value
W
wanganxp 已提交
60 61 62 63
			},
      clickTH(index:number){
        console.log("点击表头:" + index);
      }
shutao-dc's avatar
shutao-dc 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
		}
	}
</script>

<style>
	.page {
		flex: 1;
		background-color: #f5f5f5;
	}

	.content-item {
		padding: 15px;
		margin: 5px 0;
		background-color: #fff;
	}

	.text {
		font-size: 14px;
		color: #666;
		line-height: 20px;
	}

  .sift-item {
    color: #555;
    font-size: 16px;
    padding: 12px 15px;
  }

</style>