<template>
  <van-list
    v-model:loading="loadShow"
    v-bind="$attrs"
    :finished-text="finishedText"
  >
    <slot />
  </van-list>
</template>

<script lang="ts">
import { defineComponent, watch, ref } from "vue";
import { List as VanList } from  "vant";
export default defineComponent({
  name: "VLoadMore",
  props: {
    value: {
      type: Boolean,
      default: false
    },
    "finished-text": {
      type: String,
      default: "没有更多了"
    }
  },
  components: { VanList },
  setup(props, { emit }) {
    const loadShow = ref(false);
    watch(
      () => props.value,
      val => (loadShow.value = val)
    );

    watch(
      () => loadShow.value,
      val => emit("update:value", val)
    );

    return {
      loadShow
    };
  }
});
</script>
