list-view-multiplex.uvue 1.5 KB
Newer Older
1
<template>
雪洛's avatar
雪洛 已提交
2
  <scroll-view direction="horizontal" style="flex-direction: row;">
shutao-dc's avatar
shutao-dc 已提交
3 4 5
    <button class="button_item" @click="delayShow">测试延时显示</button>
  </scroll-view>
	<list-view v-show="list_show" id="listview" style="flex: 1;" show-scrollbar=false @scrolltolower="onScrollTolower">
shutao-dc's avatar
shutao-dc 已提交
6
    <list-item v-for="index in item_count" class="item" @click="itemClick(index)">
7 8 9 10 11 12 13 14 15 16
      <text >item-------<text>{{index}}</text></text>
    </list-item>
  </list-view>
</template>

<script>
	export default {
		data() {
			return {
				item_count: 20,
shutao-dc's avatar
shutao-dc 已提交
17
        list_show: true,
18 19 20 21 22 23 24 25
        listViewElement: null as UniListViewElement|null
			}
		},
    onReady() {
      this.listViewElement = uni.getElementById<UniListViewElement>('listview')
    },
		methods: {
      onScrollTolower(_: ScrollToLowerEvent) {
26
        setTimeout(() => {
27 28 29 30 31 32
          this.item_count += 20
        }, 300)
      },
      //用于自动化测试
      listViewScrollByY(y : number) {
        this.listViewElement?.scrollBy(0, y)
shutao-dc's avatar
shutao-dc 已提交
33 34 35
      },
      itemClick(index: number) {
        console.log("itemTextClick---"+index)
shutao-dc's avatar
shutao-dc 已提交
36 37 38 39 40 41 42 43
      },
      delayShow() {
        this.list_show = !this.list_show
        this.item_count += 20
        //延时显示list-view 测试list-item延时显示bug
        setTimeout(()=>{
          this.list_show = !this.list_show
        }, 400)
44 45 46 47 48 49 50 51 52 53 54 55
      }
		}
	}
</script>

<style>
  .item {
    padding: 15px;
    margin: 5px 0;
    background-color: #fff;
    border-radius: 5px;
  }
shutao-dc's avatar
shutao-dc 已提交
56 57 58
  .button_item {
    width: 200px;
  }
59 60

</style>