2022-10-27 12:59:19 +00:00
|
|
|
<script setup>
|
|
|
|
import { h, onMounted } from 'vue';
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
const $props = defineProps({
|
|
|
|
autoLoad: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
url: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
filter: {
|
|
|
|
type: Object,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-10-31 08:34:01 +00:00
|
|
|
defineExpose({ fetch });
|
|
|
|
const emit = defineEmits(['onFetch']);
|
2022-10-27 12:59:19 +00:00
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
if ($props.autoLoad) {
|
|
|
|
await fetch();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
async function fetch() {
|
|
|
|
const { data } = await axios.get($props.url, {
|
|
|
|
params: { filter: $props.filter },
|
|
|
|
});
|
|
|
|
|
2022-10-31 08:34:01 +00:00
|
|
|
emit('onFetch', data);
|
2022-10-27 12:59:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const render = () => {
|
|
|
|
return h('div', []);
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<render />
|
|
|
|
</template>
|