Created
January 14, 2022 03:51
-
-
Save ErikCH/4fc18bec5f20b42b6a07f596611d3781 to your computer and use it in GitHub Desktop.
This file contains hidden or 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