Complete the code to create a reactive variable using Vue's Composition API.
import { ref } from 'vue'; const count = [1](0);
Use ref to create a reactive primitive value like a number.
Complete the code to watch the reactive variable and log its new value.
import { ref, watch } from 'vue'; const count = ref(0); watch(count, (newVal) => { console.log([1]); });
The watcher callback receives the new value as the first argument, here named newVal.
Fix the error in the code to correctly update a reactive object property.
import { reactive } from 'vue'; const state = reactive({ count: 0 }); function increment() { state.[1] += 1; }
When using reactive, access properties directly without .value.
Fill both blanks to create a computed property that doubles the count.
import { ref, computed } from 'vue'; const count = ref(5); const double = computed(() => count[1][2]2);
.value to access the refUse .value to access the ref value and * to multiply by 2.
Fill all three blanks to create a reactive object with a nested property and update it.
import { reactive } from 'vue'; const state = reactive({ user: { name: [1] } }); function updateName(newName) { state.user.[2] = [3]; }
Initialize name with 'Alice', then update state.user.name to newName.
