issue-17030.uvue 769 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <template>
  2. <view style=" flex: 1;">
  3. <list-view id="listView" style="width: 100%; background-color: red;">
  4. <list-item v-for="(item,index) in arr" :key="index">
  5. <text class="title">{{item}}</text>
  6. </list-item>
  7. </list-view>
  8. </view>
  9. </template>
  10. <script setup>
  11. const arr = ref<number[]>([1, 2, 3, 4, 5])
  12. const addData = () => {
  13. arr.value.push(arr.value.length + 1)
  14. }
  15. const getScrollHeight = () => {
  16. const listViewElement = uni.getElementById("listView") as UniElement
  17. const scrollHeight = listViewElement.scrollHeight
  18. console.log(scrollHeight)
  19. return scrollHeight
  20. }
  21. defineExpose({
  22. addData,
  23. getScrollHeight
  24. })
  25. </script>
  26. <style>
  27. .title {
  28. height: 30px;
  29. font-size: 18px;
  30. color: #000000;
  31. text-align: center;
  32. }
  33. </style>