<template>
	<list-view id="listview" style="flex: 1;" show-scrollbar=false @scrolltolower="onScrollTolower">
    <list-item v-for="index in item_count" class="item" @click="itemClick(index)">
      <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(() => {
          this.item_count += 20
        }, 300)
      },
      //用于自动化测试
      listViewScrollByY(y : number) {
        this.listViewElement?.scrollBy(0, y)
      },
      itemClick(index: number) {
        console.log("itemTextClick---"+index)
      }
		}
	}
</script>

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

</style>
