import {
	ref,reactive,computed
} from 'vue'

export default function() {
	let finished = ref(false)
	let DataList = ref([])
	let total = ref(0)
	let loadText = reactive({
		contentdown: "点击加载更多",
		contentrefresh: "正在加载",
		contentnomore: "没有更多数据了",
	})
	// 计算属性
	let status = computed(() => {
		console.log(222,DataList,DataList.value.length < total.value,DataList.value.length ,total.value)
		if (DataList.value.length < total.value) {
			return "more";
		} else {
			finished.value = true;
			return "nomore";
		}
	});
	let MyonLoad = (e) => {
		if (status.value == "more") {
			fetch();
			finished.value = true;
			e.detail = {
				status: "loading",
			};
		}
		return e;
	}
	return {
		status,
		finished,
		DataList,
		total,
		loadText,
		MyonLoad
	}
}