list-view-multiplex.uvue 893 字节
Newer Older
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
<template>
	<list-view id="listview" style="flex: 1;" @scrolltolower="onScrollTolower">
    <list-item v-for="index in item_count" class="item">
      <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)
      }
		}
	}
</script>

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

</style>