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

H
hdx 已提交
27 28 29 30
    <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>
31 32 33
</template>

<script>
H
hdx 已提交
34 35 36 37 38 39 40 41 42 43
  export default {
    data() {
      return {
        sift_item: ["排序", "筛选"],
        list_item: [] as Array<string>,
        refresher_enabled_boolean: true,
        refresher_triggered_boolean: false,
        scroll_top_input: 0
      }
    },
shutao-dc's avatar
shutao-dc 已提交
44 45 46
    onLoad() {
      let lists : Array<string> = []
      for (let i = 0; i < 40; i++) {
shutao-dc's avatar
shutao-dc 已提交
47
        lists.push("item---" + i)
shutao-dc's avatar
shutao-dc 已提交
48 49
      }
      this.list_item = lists
50
    },
H
hdx 已提交
51 52 53 54 55 56 57 58 59 60 61 62
    methods: {
      list_view_refresherrefresh() {
        console.log("下拉刷新被触发 ")
        this.refresher_triggered_boolean = true
        setTimeout(() => {
          this.refresher_triggered_boolean = false
        }, 1500)
      },
      confirm_scroll_top_input(value : number) {
        this.scroll_top_input = value
      },
      clickTH(index : number) {
W
wanganxp 已提交
63
        console.log("点击表头:" + index);
64
      }
H
hdx 已提交
65 66
    }
  }
67 68 69
</script>

<style>
H
hdx 已提交
70 71 72 73
  .page {
    flex: 1;
    background-color: #f5f5f5;
  }
74

H
hdx 已提交
75 76
  .content-item {
    padding: 15px;
77
    margin-bottom: 10px;
H
hdx 已提交
78 79
    background-color: #fff;
  }
80

H
hdx 已提交
81 82 83 84 85
  .text {
    font-size: 14px;
    color: #666;
    line-height: 20px;
  }
shutao-dc's avatar
shutao-dc 已提交
86 87 88 89 90

  .sift-item {
    color: #555;
    font-size: 16px;
    padding: 12px 15px;
91
  }
shutao-dc's avatar
shutao-dc 已提交
92
</style>