sticky-header.uvue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <list-view :scroll-y="true" class="page" bounces="false" show-scrollbar=false :scroll-top="scroll_top_input"
  3. :refresher-enabled="refresher_enabled_boolean" :refresher-triggered="refresher_triggered_boolean"
  4. @refresherrefresh="list_view_refresherrefresh">
  5. <list-item type=1>
  6. <swiper indicator-dots="true" circular="true" style="height: 240px;">
  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>
  10. </swiper-item>
  11. </swiper>
  12. </list-item>
  13. <list-item class="content-item" type=2>
  14. <text class="text">向上滑动页面,体验sticky-header吸顶效果。</text>
  15. </list-item>
  16. <sticky-section>
  17. <sticky-header>
  18. <scroll-view style="background-color: #f5f5f5; flex-direction: row;" direction="horizontal"
  19. :show-scrollbar="false">
  20. <view style="align-self: flex-start; flex-direction: row;">
  21. <text ref="swipertab" class="sift-item" v-for="(name,index) in sift_item" @click="clickTH(index)">
  22. {{name}}
  23. </text>
  24. </view>
  25. </scroll-view>
  26. </sticky-header>
  27. <list-item v-for="(item,index) in list_item" :key="index" class="content-item" type=3>
  28. <text class="text">{{item}}</text>
  29. </list-item>
  30. </sticky-section>
  31. </list-view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. sift_item: ["排序", "筛选"],
  38. list_item: [] as Array<string>,
  39. refresher_enabled_boolean: true,
  40. refresher_triggered_boolean: false,
  41. scroll_top_input: 0
  42. }
  43. },
  44. onLoad() {
  45. this.loadListData()
  46. },
  47. methods: {
  48. list_view_refresherrefresh() {
  49. console.log("下拉刷新被触发 ")
  50. this.refresher_triggered_boolean = true
  51. setTimeout(() => {
  52. this.refresher_triggered_boolean = false
  53. }, 1500)
  54. },
  55. confirm_scroll_top_input(value : number) {
  56. this.scroll_top_input = value
  57. },
  58. clickTH(index : number) {
  59. console.log("点击表头:" + index);
  60. },
  61. loadListData() {
  62. let lists : Array<string> = []
  63. for (let i = 0; i < 40; i++) {
  64. lists.push("item---" + i)
  65. }
  66. this.list_item = lists
  67. },
  68. //自动化测试使用
  69. clearListData() {
  70. this.list_item = []
  71. }
  72. }
  73. }
  74. </script>
  75. <style>
  76. .page {
  77. flex: 1;
  78. background-color: #f5f5f5;
  79. }
  80. .content-item {
  81. padding: 15px;
  82. margin-bottom: 10px;
  83. background-color: #fff;
  84. }
  85. .text {
  86. font-size: 14px;
  87. color: #666;
  88. line-height: 20px;
  89. }
  90. .sift-item {
  91. color: #555;
  92. font-size: 16px;
  93. padding: 12px 15px;
  94. }
  95. </style>