sticky-header.uvue 2.3 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 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
	:refresher-triggered="refresher_triggered_boolean" @refresherrefresh="list_view_refresherrefresh">
    <list-item type = 1>
      <image src="/static/shuijiao.jpg" style="height: 240px;"></image>
    </list-item>
    <list-item class="content-item" type = 2>
			<text class="text">向上滑动页面,体验sticky-header吸顶效果。</text>
		</list-item>
		<sticky-header>
      <scroll-view style="background-color: white; flex-direction: row;" :scroll-x="true" :scroll-y="false" :show-scrollbar="false">
        <view class="flex-row" style="align-self: flex-start; flex-direction: row;">
          <text ref="swipertab" class="sift-item"
            v-for="name in sift_item" @click="">
            {{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 已提交
31
				sift_item: ["最新上架", "免费热榜", "付费热榜", "热门总榜", "观看最多", "平分最高", "下载总榜", "访问排行", "回复总榜"],
shutao-dc's avatar
shutao-dc 已提交
32 33
				list_item: [] as Array<string>,
				refresher_enabled_boolean: true,
shutao-dc's avatar
shutao-dc 已提交
34 35
				refresher_triggered_boolean: false,
				scroll_top_input: 0
shutao-dc's avatar
shutao-dc 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
			}
		},
    onLoad() {
      let lists : Array<string> = []
      for (let i = 0; i < 40; i++) {
        lists.push("list-item-" + i)
      }
      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 已提交
52 53 54 55
			},
			confirm_scroll_top_input(value : number) {
			  this.scroll_top_input = value
			}
shutao-dc's avatar
shutao-dc 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
		}
	}
</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 {
    background-color: #f5f5f5;
    color: #555;
    font-size: 16px;
    padding: 12px 15px;
  }

</style>