Interview Q&A · questions with model answers
Vue.js Developer Interview Questions
Part of the study plan for: Frontend Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked computed, watch or watchEffect: when do you use each?
computed derives a value from reactive state and caches it until its dependencies change; use it for anything you would display or pass on. watch runs a side effect when specific sources change,…
-
Most asked How do props work, and what is one-way data flow?
Props pass data from parent to child; when the parent's value changes, the child receives the update. The child must not mutate a prop: data flows down, and changes go back up as events, so the…
-
Most asked Describe the Vue component lifecycle hooks and what you use them for.
Composition API hooks: onBeforeMount, onMounted (DOM available; start DOM-dependent work), onBeforeUpdate / onUpdated, onBeforeUnmount / onUnmounted (clean up timers, listeners, subscriptions), plus…
-
Most asked How does v-model work on components, and what does defineModel do?
On a component, v-model is shorthand for passing a modelValue prop and listening for update:modelValue. defineModel() (stable since Vue 3.4) declares that pair in one line and returns a ref you can…
-
Most asked Explain default, named and scoped slots.
Slots let a parent pass template content into a child. The default slot receives untargeted content; named slots (<template #header>) target specific outlets; scoped slots let the child pass data…
-
Most asked How does server-side rendering work with Vue, and what does Nuxt add?
With SSR, the server renders components to HTML (renderToString from vue/server-renderer), sends it so users and crawlers see content immediately, and the client then hydrates it: Vue attaches…
-
Most asked How does Vue's virtual DOM and compiler make updates efficient?
Templates are compiled into render functions that produce virtual DOM. Vue's compiler adds hints: static content is hoisted and skipped on updates, dynamic nodes get patch flags describing what can…
-
How do components emit events, and how do you declare them?
A child emits with emit('name', payload) (from defineEmits in <script setup>, or $emit in templates), and the parent listens with @name="handler". Declaring emits documents the component's API,…
-
How do you handle forms and validation in Vue?
Bind inputs with v-model (with .trim, .number and .lazy modifiers as needed), keep form state in a reactive object or refs, validate on blur and submit with computed error messages or a library…
-
How do you handle errors in a Vue application?
Use app.config.errorHandler to catch errors from rendering, lifecycle hooks, watchers and event handlers globally (report them to Sentry or similar), onErrorCaptured in components to handle errors…
-
Can you share state without Pinia, and what is the SSR pitfall?
Yes: a module that exports a reactive() object or refs works as a simple store in a client-only app. In SSR, though, module-level state is shared by every request on the server, so one user's data…
-
How do sibling components communicate?
Through their common parent: one emits an event, the parent updates its state, and passes it to the other as a prop. For distant components, use provide/inject within a subtree or a Pinia store for…
-
How do memory leaks happen in Vue apps, and how do you prevent them?
Leaks come from things Vue does not clean up for you: global event listeners, intervals and timeouts, subscriptions (WebSockets, observers), third-party library instances, and references stored in…
-
How can changing a component's key help, and when is it the wrong tool?
Changing the key on a component forces Vue to destroy it and create a fresh instance, which resets all internal state. It is a simple way to reset a form or restart a component when an ID changes…
-
How do transitions work in Vue?
<Transition> applies enter and leave CSS classes (v-enter-from, v-enter-active, v-leave-to, ...) or JavaScript hooks when its single child is inserted or removed (via v-if, v-show or a changing…
-
How do class and style bindings work?
:class accepts a string, an object ({ active: isActive, 'text-danger': hasError }) or an array, and merges with a static class; :style accepts an object or array of objects with camelCase or…