Complete the code to import the Vue Composition API function used to create reactive state.
import { [1] } from 'vue';
The ref function creates a reactive reference to a value, which is a basic building block in Vue composables.
Complete the code to define a composable function that returns a reactive count.
export function useCounter() {
const count = [1](0);
return { count };
}The ref function is used to create a reactive primitive value like a number inside a composable.
Fix the error in the composable by completing the code to update the count value.
export function useCounter() {
const count = ref(0);
function increment() {
count[1]++;
}
return { count, increment };
}In Vue's ref, the actual value is accessed and updated via the .value property.
Fill both blanks to create a composable that returns a reactive object with a method to reset the count.
import { [1], [2] } from 'vue'; export function useCounter() { const state = [1]({ count: 0 }); function reset() { state.count = 0; } return { state, reset }; }
reactive creates a reactive object, and ref is also imported but not used here. The blank for import includes both to show common imports.
Fill all three blanks to create a composable that uses a computed property to double the count.
import { [1], [2], [3] } from 'vue'; export function useCounter() { const count = [1](0); const double = [3](() => count.value * 2); return { count, double }; }
ref creates the reactive count, computed creates the double value, and reactive is imported but unused here to show common imports.