<template>
<div>
<h1>User Profile</h1>
<p>Name: {{ userProfile.name }}</p>
<p>Email: {{ userProfile.email }}</p>
</div>
</template>
<script>
import { ref, onMounted } from 'vue';
export default {
setup() {
const userProfile = ref(null);
async function fetchUserProfile() {
const response = await fetch('https://api.example.com/user');
userProfile.value = await response.json();
}
onMounted(fetchUserProfile);
return { userProfile };
}
}
</script>
<template>
<div>
<Suspense>
<template #default>
<UserProfile />
</template>
<template #fallback>
<div>Loading user profile...</div>
</template>
</Suspense>
</div>
</template>
<script>
import UserProfile from './components/UserProfile.vue';
export default {
components: {
UserProfile
}
}
</script>