📖 Scenario: You are learning about three popular tools to build websites: Vue, React, and Angular. Each helps you make interactive web pages but works in different ways.
🎯 Goal: You will create a simple Vue component that shows a list of features. Then you will add a setting to choose which framework to compare. Next, you will write code to show differences based on the chosen framework. Finally, you will complete the component so it displays the correct information clearly.
📋 What You'll Learn
Create a Vue component using the Composition API with <script setup>
Use a reactive variable to hold the selected framework name
Use a list of features stored in a reactive object
Use a v-if or @switch control flow to show differences
Add accessible labels and semantic HTML for clarity
💡 Why This Matters
🌍 Real World
Comparing frameworks helps developers choose the right tool for their projects by understanding differences clearly.
💼 Career
Knowing how Vue differs from React and Angular is useful for frontend developers working in teams or deciding on technology stacks.
Progress0 / 4 steps
1
DATA SETUP: Create a reactive object with Vue features
Create a Vue component with <script setup> and define a reactive object called features with these exact entries: reactive({ templateSyntax: 'Simple and flexible', learningCurve: 'Gentle', ecosystem: 'Growing but smaller' }).
Vue
Hint
Use reactive from Vue to create an object with the exact keys and values.
2
CONFIGURATION: Add a reactive variable for selected framework
Add a reactive variable called selectedFramework using ref and set its initial value to 'React'.
Vue
Hint
Use ref to create a reactive string variable with the exact name and value.
3
CORE LOGIC: Show differences based on selected framework
Inside the template, use a <template> block and write a <div> that uses v-if or @switch on selectedFramework to display these exact texts for each framework: For 'React', show 'Uses JSX for templating.'; for 'Angular', show 'Full framework with TypeScript.'; for 'Vue', show 'Progressive framework with templates.'.
Vue
Hint
Use Vue's v-if and v-else-if directives inside the template to show the exact text for each framework.
4
COMPLETION: Add accessible label and semantic structure
Wrap the framework differences inside a <section> with an aria-label attribute set to 'Framework differences'. Also, add a <h2> heading with the text 'Compare Vue, React, and Angular' above the differences.
Vue
Hint
Use semantic HTML tags and add aria-label for accessibility.
Practice
(1/5)
1. Which of the following best describes how Vue differs from React and Angular?
easy
A. Vue uses HTML-like templates and simple reactive data, making it easier to learn.
B. Vue requires JSX for all components, unlike React and Angular.
C. Vue is a full framework with strict rules like Angular.
D. Vue does not support component-based architecture.
Solution
Step 1: Understand Vue's template style
Vue uses HTML-like templates which are easy for beginners to understand, unlike React's JSX or Angular's complex templates.
Step 2: Compare Vue's learning curve
Vue's simple reactive data system makes it easier to learn compared to Angular's full framework approach and React's JSX syntax.
Final Answer:
Vue uses HTML-like templates and simple reactive data, making it easier to learn. -> Option A
Quick Check:
Vue = Easy templates + reactive data [OK]
Hint: Vue uses HTML templates, React uses JSX, Angular is full framework [OK]
Common Mistakes:
Confusing Vue's template syntax with React's JSX
Thinking Vue is as complex as Angular
Believing Vue does not use components
2. Which syntax correctly defines a Vue 3 component using the Composition API?
Step 1: Understand reactive ref and template binding
The message is a reactive ref initialized to 'Hello Vue'. The template shows its value with {{ message }} which Vue unwraps automatically.
Step 2: Analyze setTimeout effect
After 1 second, message.value changes to 'Updated Vue', so the displayed text updates reactively.
Final Answer:
<div>Hello Vue</div> initially, then changes to <div>Updated Vue</div> after 1 second -> Option D
Quick Check:
Reactive ref updates template text after delay [OK]
Hint: Vue ref updates template reactively after value changes [OK]
Common Mistakes:
Thinking template shows 'message.value' literally
Expecting no update after setTimeout
Believing ref() cannot be used in templates
4. Identify the error in this Vue 3 component code and how to fix it:
<script setup>
import { reactive } from 'vue'
const state = reactive({ count: 0 })
function increment() {
state.count++
}
</script>
<template>
<button @click="increment">Count: {{ state.count }}</button>
</template>
medium
A. The increment function is not exposed to the template; add defineExpose({ increment }).
B. No error; code works correctly as is.
C. Reactive state should use ref() instead of reactive().
D. The @click event should be @click="increment()" with parentheses.
Solution
Step 1: Check function exposure in <script setup>
In Vue 3's <script setup>, all top-level functions and variables are automatically exposed to the template.
Step 2: Verify reactive usage and event binding
Using reactive() for state is correct. The event binding @click="increment" works without parentheses.
Final Answer:
No error; code works correctly as is. -> Option B
Quick Check:
script setup auto exposes functions [OK]
Hint: In script setup, functions auto-expose to template [OK]
Common Mistakes:
Thinking functions need defineExpose in script setup
Adding parentheses in @click unnecessarily
Confusing reactive() with ref() for simple objects
5. You want to build a small interactive widget that updates a message when a button is clicked. Which Vue feature makes this simpler compared to Angular and React?
hard
A. Vue forces you to write JSX for all components like React.
B. Vue requires writing class components with decorators like Angular.
C. Vue's use of HTML-like templates with automatic reactive updates without JSX or decorators.
D. Vue does not support reactive data binding, unlike React and Angular.
Solution
Step 1: Understand Vue's template and reactivity advantages
Vue uses simple HTML-like templates and reactive data that update the UI automatically without extra syntax like JSX or decorators.
Step 2: Compare with Angular and React
Angular requires decorators and more setup; React uses JSX which mixes HTML and JavaScript syntax. Vue's approach is simpler for small widgets.
Final Answer:
Vue's use of HTML-like templates with automatic reactive updates without JSX or decorators. -> Option C
Quick Check:
Vue = simple templates + reactive updates [OK]
Hint: Vue uses simple templates and reactive data, no JSX or decorators [OK]
Common Mistakes:
Thinking Vue requires JSX like React
Believing Vue uses decorators like Angular
Assuming Vue lacks reactive data binding
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.