0
0
Astroframework~20 mins

Vue components in Astro - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Vue in Astro Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does a Vue component behave inside Astro?
You include a Vue component in an Astro page using <Component />. What happens when you load the page in the browser?
Astro
<script setup>
import MyVue from '../components/MyVue.vue';
</script>

<MyVue />
AThe Vue component is ignored and does not render at all.
BThe Vue component renders only on the server and is static on the client.
CThe Vue component renders only on the client without server rendering.
DThe Vue component renders on the server and hydrates on the client for interactivity.
Attempts:
2 left
💡 Hint
Think about how Astro handles frameworks for interactivity.
📝 Syntax
intermediate
1:30remaining
Correct way to import a Vue component in Astro
Which import statement correctly imports a Vue component named Button.vue in an Astro file?
Aimport Button from '../components/Button.vue';
Bimport { Button } from '../components/Button.vue';
Cconst Button = require('../components/Button.vue');
Dimport Button from '../components/Button.js';
Attempts:
2 left
💡 Hint
Vue components use default exports and .vue extension.
🔧 Debug
advanced
2:30remaining
Why does this Vue component not hydrate in Astro?
You have this Astro code: But the counter does not respond to clicks in the browser. What is missing?
Astro
<script setup>
import Counter from '../components/Counter.vue';
</script>

<Counter />
AAstro does not support Vue components with events.
BThe Vue component file is missing a <code>&lt;script&gt;</code> block.
CYou forgot to add a client directive like <code>client:load</code> to hydrate the component.
DYou need to import Vue globally in the Astro file.
Attempts:
2 left
💡 Hint
Astro requires client directives to hydrate interactive components.
state_output
advanced
2:00remaining
What is the output after clicking the button twice?
Given this Vue component used in Astro: What will the button text show after clicking it twice in the browser?
A"Clicked 2 times"
B"Clicked 0 times"
C"Clicked NaN times"
DButton does not update text after clicks
Attempts:
2 left
💡 Hint
Vue's ref tracks reactive state changes.
🧠 Conceptual
expert
3:00remaining
How does Astro optimize Vue components for performance?
Astro uses partial hydration for Vue components. What does this mean?
AAstro compiles Vue components into plain HTML with no JavaScript.
BAstro sends only the static HTML first, then hydrates Vue components on demand to reduce JavaScript load.
CAstro bundles all Vue components into one large JavaScript file loaded at once.
DAstro disables Vue reactivity to improve speed.
Attempts:
2 left
💡 Hint
Think about how Astro reduces JavaScript sent to the browser.