list-view-children-in-slot.uvue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view style="flex:1;padding-bottom: 20px;">
  4. <!-- #endif -->
  5. <view>
  6. <page-head title="getApp"></page-head>
  7. <view class="uni-padding-wrap">
  8. <list-view-wrapper>
  9. <template #default>
  10. <list-item v-for="item in list" :key="item">
  11. <text class="text-in-list-item">{{item}}</text>
  12. </list-item>
  13. </template>
  14. <template #second>
  15. <list-item v-for="item in list" :key="item">
  16. <text class="text-in-list-item">{{item}}</text>
  17. </list-item>
  18. </template>
  19. </list-view-wrapper>
  20. <button id="add-btn" class="uni-common-mt" @click="addItem">add item</button>
  21. <button id="empty-btn" class="uni-common-mt" @click="emptyList">empty list</button>
  22. </view>
  23. </view>
  24. <!-- #ifdef APP -->
  25. </scroll-view>
  26. <!-- #endif -->
  27. </template>
  28. <script>
  29. import ListViewWrapper from './ListViewWrapper.uvue'
  30. export default {
  31. components: { ListViewWrapper },
  32. data() {
  33. return {
  34. list: [0, 1, 2]
  35. }
  36. },
  37. methods: {
  38. addItem() {
  39. this.list.push(this.list.length)
  40. },
  41. emptyList() {
  42. this.list = []
  43. }
  44. }
  45. }
  46. </script>