list-view-refresh.uvue 1.1 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1 2 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<template>
  <list-view v-if="list_show" id="listview" style="flex: 1;" show-scrollbar=false :refresher-enabled="true"
    :refresher-triggered="refresherTriggered" @refresherrefresh="onRefresherrefresh">
    <list-item class="item">
      <text>向下滑动触发下拉刷新</text>
    </list-item>
    <list-item v-for="index in item_count" class="item">
      <text>item-------{{index}}</text>
    </list-item>
  </list-view>
</template>

<script>
  export default {
    data() {
      return {
        item_count: 20,
        list_show: false,
        refresherTriggered: true
      }
    },
    onLoad() {
      //延迟显示list-view
      setTimeout(() => {
        this.list_show = true;
      }, 500)
    },
    methods: {
      onRefresherrefresh() {
        this.refresherTriggered = true;
        setTimeout(() => {
          this.refresherTriggered = false;
        }, 1000)
      }
    }
  }
</script>
<style>
  .item {
    padding: 15px;
    margin: 0 0 5px 0;
    background-color: #fff;
    border-radius: 5px;
  }

  .button_item {
    width: 200px;
  }
</style>