uni-recycle-item.uvue 776 字节
Newer Older
1
<template>
2
  <view class="item-container">
3 4 5 6 7
    <slot></slot>
  </view>
</template>

<script>
8 9 10 11 12
  /**
   * recycle-item 长列表子项组件
   * @description 用于展示超长列表数据每一项
   * @property {any[]} item 当前组件渲染的列表项
   */
13 14 15 16 17 18 19 20 21
  export default {
    name: "custom-list-item",
    props: {
      item: {
        type: Object as PropType<any>,
        required: true
      }
    },
    inject: {
22 23
      setCachedSize: {
        type: Function as PropType<(item : any, size : number) => void>
24 25 26
      },
    },
    mounted() {
27
      uni.createSelectorQuery().in(this).select('.item-container').boundingClientRect().exec((ret) => {
28
        this.setCachedSize(this.item, (ret[0] as NodeInfo).height!)
29 30 31 32 33 34 35
      })
    }
  }
</script>

<style>

36
</style>