list-view-multiplex.uvue 1.0 KB
Newer Older
1
<template>
2
	<list-view id="listview" style="flex: 1;" show-scrollbar=false @scrolltolower="onScrollTolower">
shutao-dc's avatar
shutao-dc 已提交
3
    <list-item v-for="index in item_count" class="item" @click="itemClick(index)">
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
      <text >item-------<text>{{index}}</text></text>
    </list-item>
  </list-view>
</template>

<script>
	export default {
		data() {
			return {
				item_count: 20,
        listViewElement: null as UniListViewElement|null
			}
		},
    onReady() {
      this.listViewElement = uni.getElementById<UniListViewElement>('listview')
    },
		methods: {
      onScrollTolower(_: ScrollToLowerEvent) {
        setTimeout(function(){
          this.item_count += 20
        }, 300)
      },
      //用于自动化测试
      listViewScrollByY(y : number) {
        this.listViewElement?.scrollBy(0, y)
shutao-dc's avatar
shutao-dc 已提交
29 30 31
      },
      itemClick(index: number) {
        console.log("itemTextClick---"+index)
32 33 34 35 36 37 38 39 40 41 42 43 44 45
      }
		}
	}
</script>

<style>
  .item {
    padding: 15px;
    margin: 5px 0;
    background-color: #fff;
    border-radius: 5px;
  }

</style>