<template>
  <List
    v-model:loading="loadShow"
    :offset="50"
    :immediate-check="false"
    :finished="finished"
    :finished-text="finished_text"
    @load="onLoad"
  >
    <slot />
  </List>
</template>

<script lang="ts">
/*
 * @Author: Liao.xiuli
 * @Date: 2021-09-18 11:18:59
 * @Last Modified by: Liao.xiuli
 * @Last Modified time: 2022-10-27 15:26:45
 */
export default {
  name: "WlLoadMore",
};
</script>

<script setup lang="ts">
import { List } from "vant";
import { ref, watch, watchEffect } from "vue";
type Props = {
  modelValue?: boolean;
  finished?: boolean;
  finished_text?: string;
};
const props = withDefaults(defineProps<Props>(), {
  modelValue: false,
  finished: false,
  finished_text: "没有更多了",
});

const emit = defineEmits<{
  (e: "load");
  (e: "update:modelValue", val: boolean);
}>();

const loadShow = ref(false);

const onLoad = () => emit("load");

watchEffect(() => {
  loadShow.value = props.modelValue;
});

watch(
  () => loadShow.value,
  (val) => {
    emit("update:modelValue", val);
  },
);
</script>
