-
-
Save digitalsparky/48351e41f7816a426fe128550454d30d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup lang="ts"> | |
import { ref, useSlots, getCurrentInstance } from "vue"; | |
const props = defineProps<{ url: string }>(); | |
const slots = useSlots(); | |
let res = ref(""); | |
let loading = ref(true); | |
fetch(props.url) | |
.then(response => response.json()) | |
.then(response => { | |
res.value = response; | |
loading.value = false; | |
}); | |
getCurrentInstance().render = () => | |
slots.default({ | |
res: res.value, | |
loading: loading.value | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment