<template>
<div>
<div v-if="loading">Loading...</div>
<div v-else>{{ data.value }}</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
const data = ref(null);
const loading = ref(true);
async function fetchData() {
await new Promise((resolve) => setTimeout(resolve, 2000));
console.log("333");
data.value = '<p>HTML</p>';
loading.value = false;
}
await fetchData();
</script>
Removing wait works, but I need to use wait to get the data asynchronously, what should I do?