This component shows a greeting message and an input box. When you type in the input, the message updates automatically. The input has an accessible label and simple styling for clarity.
Without reactivity, changes to message won't update the template automatically.
Final Answer:
The message variable is not reactive, so template won't update if changed. -> Option B
Quick Check:
Non-reactive data won't update template [OK]
Hint: Use ref() or reactive() for reactive data in templates [OK]
Common Mistakes:
Thinking plain variables are reactive by default
Believing template syntax {{ }} is wrong
Assuming imports are always required in script setup
5. You want to create a Vue component that shows a list of tasks and updates automatically when tasks change. Which template approach best supports this?
hard
A. Use JavaScript to manually update the DOM elements outside the template.
B. Write tasks directly in HTML without binding to data.
C. Use a template with v-for to loop over a reactive tasks array and display each task.
D. Render tasks as a plain string inside a single <div> without looping.
Solution
Step 1: Identify how Vue templates handle lists reactively
Vue uses v-for directive in templates to loop over reactive arrays and update the DOM automatically.
Step 2: Evaluate options for dynamic list rendering
Only Use a template with v-for to loop over a reactive tasks array and display each task. uses v-for with reactive data, enabling automatic updates when tasks change.
Final Answer:
Use a template with v-for to loop over a reactive tasks array and display each task. -> Option C
Quick Check:
v-for with reactive array = dynamic list updates [OK]
Hint: Use v-for on reactive arrays to render dynamic lists [OK]
Common Mistakes:
Hardcoding list items in HTML without data binding
Manually manipulating DOM instead of using templates
Rendering list as plain string without looping
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.