list-view-children-in-slot.uvue 1.0 KB
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
<template>
  <!-- #ifdef APP -->
  <scroll-view style="flex:1;padding-bottom: 20px;">
  <!-- #endif -->
    <view>
      <page-head title="getApp"></page-head>
      <view class="uni-padding-wrap">
        <list-view-wrapper>
          <list-item v-for="item in list" :key="item">
            <text class="text-in-list-item">{{item}}</text>
          </list-item>
        </list-view-wrapper>
        <button id="add-btn" class="uni-common-mt" @click="addItem">add item</button>
        <button id="empty-btn" class="uni-common-mt" @click="emptyList">empty list</button>
      </view>
    </view>
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>

<script>
  import ListViewWrapper from './ListViewWrapper.uvue'

  export default {
    components: { ListViewWrapper },
    data() {
      return {
        list: [0, 1, 2]
      }
    },
    methods: {
      addItem(){
        this.list.push(this.list.length)
      },
      emptyList(){
        this.list = []
      }
    }
  }
</script>