Complete the code to declare a reactive loading state using Vue's Composition API.
import { [1] } from 'vue'; const isLoading = [1](false);
We use ref to create a simple reactive variable for loading state.
Complete the code to toggle the loading state to true when a function starts.
function fetchData() {
isLoading.[1] = true;
// simulate data fetch
}When using ref, the actual value is accessed and set via the .value property.
Fix the error in the template to show 'Loading...' only when loading is true.
<template> <div v-if="[1]">Loading...</div> </template>
The reactive variable is named isLoading and must match exactly in the template.
Fill both blanks to create a reactive object with loading and data properties.
import { [1] } from 'vue'; const state = [2]({ loading: false, data: null });
Use reactive to create a reactive object with multiple properties.
Fill all three blanks to create a loading state, fetch data asynchronously, and update the state.
import { [1] } from 'vue'; const isLoading = [2](false); async function loadData() { isLoading.[3] = true; await fetch('https://api.example.com/data'); isLoading.value = false; }
We import and use ref to create isLoading. The value is accessed and set with .value.