Vue Developer interview questions
100 real questions with model answers and explanations for Junior Vue Developer candidates.
See a Vue Developer resume example →Practice with flashcards
Spaced repetition · Hunter Pass
Questions
Vue is a JavaScript framework that renders a user interface from reactive state and component templates.
- Declarative code describes what the UI should look like for the current data instead of manually editing DOM nodes.
- When tracked state changes, Vue updates the affected parts of the rendered output.
- Components split the interface into reusable units with their own inputs, behavior, and template.
Why interviewers ask this: The interviewer checks whether you understand Vue's basic programming model rather than only its syntax.
A Vue Single-File Component usually keeps logic, markup, and styles in one .vue file.
- The script or script setup section defines state, imports, props, emitted events, and component logic.
- The template section declares the HTML structure and Vue bindings.
- The style section contains CSS and may use scoped so its selectors are limited to that component.
Why interviewers ask this: A strong answer identifies the responsibility of each SFC section without mixing presentation and behavior.
createApp creates a Vue application instance, and mount renders its root component into a DOM container.
- The root component starts the component tree for that application.
- Plugins, global components, and application-level provide values are normally registered before mounting.
- The selector or element passed to mount identifies the existing page container Vue will control.
Why interviewers ask this: The interviewer checks whether you understand how a Vue component tree is bootstrapped.
Vue represents rendered output as virtual nodes and compares new output with the previous one before updating the real DOM.
- A component render produces a lightweight JavaScript description of the UI.
- Reactive changes cause Vue to render the affected component again and patch only necessary DOM operations.
- Stable keys and predictable templates help Vue match old and new child nodes correctly.
Why interviewers ask this: A strong answer explains the render-and-patch model without claiming that the entire page DOM is rebuilt.
Vue records which reactive values are read by an active effect and reruns that effect when those values change.
- Templates, computed values, and watchers can act as reactive effects.
- ref uses an object with a reactive value property, while reactive uses a Proxy for object access.
- Only tracked reads create dependencies, so unrelated state changes do not need to update every component.
Why interviewers ask this: The interviewer is testing the basic relationship among reactive reads, dependencies, and updates.
ref creates a reactive container whose current value is read and changed through its value property in JavaScript.
- It works with primitives such as numbers and strings as well as objects.
- Assigning to count.value notifies templates, computed values, and watchers that depend on it.
- Templates normally unwrap refs automatically, so they use count rather than count.value.
Why interviewers ask this: A strong answer knows both the JavaScript and template access rules for refs.
reactive returns a deeply reactive Proxy for an object, array, Map, or Set.
- Property reads and writes are tracked through the Proxy without a value wrapper.
- The original plain object is not the same identity as the returned Proxy, so application code should use the Proxy.
- reactive is not intended for primitive values because primitives have no properties to intercept.
Why interviewers ask this: The interviewer checks whether you understand Proxy-based object reactivity and its limits.
Use ref for standalone values and replaceable state, and use reactive for a group of object properties updated in place.
- ref handles primitives directly and keeps reactivity when the whole value is replaced.
- reactive offers convenient property access for an object but destructuring those properties can lose reactivity.
- A consistent local convention matters more than forcing all state into one primitive.
Why interviewers ask this: A strong answer makes a practical choice while recognizing the reactivity trade-offs of each API.
Vue removes much of the value syntax in templates, but unwrapping rules depend on where the ref appears.
- A top-level ref exposed to a template is normally read and assigned without .value.
- A ref stored as a property of a reactive object is unwrapped during property access.
- Refs inside arrays or native collections are not automatically unwrapped, so their value property is still needed.
Why interviewers ask this: The interviewer checks whether you can avoid common confusion between script and template ref access.
toRefs converts each reactive property into a linked ref so destructuring does not break reactivity.
- Plain destructuring copies current property values and disconnects primitive variables from the Proxy.
- Each ref returned by toRefs reads from and writes to the corresponding source property.
- It is useful when a composable returns a reactive object whose fields callers want to destructure.
Why interviewers ask this: A strong answer understands why destructuring a Proxy property differs from retaining a reactive link.
The Options API groups code by option type, while the Composition API groups related state and behavior together.
- Options components use sections such as data, computed, methods, watch, and lifecycle hooks.
- Composition components create refs, computed values, watchers, and hooks inside setup or script setup.
- Both use the same Vue reactivity and can build valid components, so the choice is mainly about organization and reuse.
Why interviewers ask this: The interviewer checks whether you can compare the APIs without treating one as a different rendering system.
script setup is compile-time syntax that makes Composition API declarations directly available to the template.
- Imported components can be used in the template without a separate components registration object.
- Top-level variables, functions, refs, and computed values are visible to the template.
- Compiler macros such as defineProps and defineEmits declare the component interface without runtime imports.
Why interviewers ask this: A strong answer identifies script setup as SFC compiler syntax rather than a function that runs outside setup.
Local registration makes a component available only where it is imported, while global registration exposes it throughout an application.
- Local imports make dependencies visible and allow unused components to be removed more easily from builds.
- Global registration can suit a small set of truly universal UI primitives.
- Registering many feature components globally hides dependencies and increases the risk of name collisions.
Why interviewers ask this: The interviewer checks whether component availability is scoped deliberately.
Props are declared inputs passed from a parent component to a child component.
- The child declares accepted prop names and may also declare their types, requirements, and defaults.
- A parent binds dynamic values with v-bind or the colon shorthand.
- Props follow one-way data flow and should be treated as readonly inside the child.
Why interviewers ask this: A strong answer presents props as an explicit readonly component interface.
Prop options document and check the values a parent is expected to pass.
- type performs a development-time runtime check against constructors such as String or Number.
- required reports an omitted prop, while validator can enforce an additional rule.
- Object and array defaults should be returned by a factory function so component instances do not share one mutable value.
Why interviewers ask this: The interviewer checks whether you can define useful prop contracts and safe defaults.
A child declares and emits custom events, and the parent listens to those events on the child component.
- In script setup, defineEmits declares event names and returns the emit function.
- The child can include a payload, such as emit('save', formData).
- Component events do not bubble through the component tree like native DOM events.
Why interviewers ask this: A strong answer understands explicit upward communication and the non-bubbling behavior of component events.
Direct prop mutation breaks one-way data flow because the parent owns the source value.
- A parent update can overwrite a child mutation on the next render.
- The child should emit an event when it wants the parent to change shared state.
- For editable temporary state, the child may create a local copy and define how it synchronizes with new prop values.
Why interviewers ask this: The interviewer checks whether component ownership remains predictable instead of creating two writers for one value.
Component v-model combines a value prop with a matching update event to create two-way binding syntax for the parent.
- The default Vue 3 contract uses the modelValue prop and the update:modelValue event.
- The child still does not mutate the prop directly and emits the new value instead.
- Named v-model bindings allow a component to expose more than one independently bound value.
Why interviewers ask this: A strong answer explains the prop-and-event contract hidden by component v-model syntax.
Fallthrough attributes are undeclared attributes and listeners that Vue applies to a component's root element.
- Common examples include class, style, id, and native event listeners.
- A component with multiple root nodes must choose where attributes belong because Vue cannot infer one root target.
- inheritAttrs and the attrs object allow a component to disable or redirect automatic inheritance.
Why interviewers ask this: The interviewer checks whether wrapper components can preserve ordinary HTML attributes correctly.
v-bind evaluates a JavaScript expression and assigns its result to an HTML attribute or component prop.
- The shorthand :href is equivalent to v-bind:href.
- Binding class and style supports strings, arrays, and objects for conditional styling.
- v-bind without an argument can apply all properties of an object as attributes or props.
Why interviewers ask this: A strong answer distinguishes dynamic binding from writing a literal HTML attribute.
Locked questions
- 21
What does v-on do in a Vue template?
vue - 22
What are Vue event modifiers used for?
vue - 23
What is the difference between v-if and v-show?
- 24
How does v-for render a list?
- 25
Why does Vue need a key for list items?
vue - 26
Why should v-if and v-for usually not be placed on the same element?
- 27
How does v-model work with native form controls?
forms - 28
What do the .lazy, .number, and .trim modifiers change for v-model?
forms - 29
What is a computed property in Vue?
reactivityvue - 30
When should you use a computed property instead of a method in a template?
reactivity - 31
What is a writable computed property?
reactivity - 32
What does watch do in the Composition API?
composition-apiapioop - 33
How does watchEffect differ from watch?
reactivity - 34
What do the immediate and deep watch options do?
- 35
What are the main phases of a Vue component lifecycle?
componentsvue - 36
What should onMounted be used for?
- 37
What should onUpdated be used for?
- 38
Why is cleanup commonly placed in onUnmounted?
- 39
What are default and named slots?
- 40
What is a scoped slot in Vue?
componentsvue - 41
What is a template ref and when is it available?
components - 42
Why should parent components avoid controlling children mainly through component template refs?
components - 43
How do dynamic components work in Vue?
componentsvue - 44
What do RouterLink and RouterView do in Vue Router?
routingvue - 45
What is the difference between route params and query parameters?
queries - 46
How do you navigate programmatically with Vue Router?
routingvue - 47
How do nested routes and catch-all routes work in Vue Router?
routingvue - 48
What are state, getters, and actions in a Pinia store?
state-management - 49
How do components use a Pinia store without losing reactivity?
reactcomponentsreactivity - 50
When should state stay local, and when should it move to Pinia or Vuex?
state-management - 51
How would you build a reusable Vue button component with several visual variants?
componentsvue - 52
How would you design a reusable product card component?
componentsdesign - 53
How would you split a large Vue page into components?
componentsvue - 54
How would you implement a reusable Composition API feature as a composable?
composition-apicomposablesapi - 55
How would you implement an accessible show-and-hide details component?
components - 56
How would you implement client-side filtering for a list in Vue?
vue - 57
How would you implement a modal component controlled by its parent?
componentsforms - 58
How would you implement adding and removing items through a child list component?
components - 59
How would you build a basic Vue form with text, select, and checkbox fields?
formsvue - 60
How would you bind a group of checkboxes or radio buttons with v-model?
forms - 61
How would you add client-side validation to a Vue form?
formsvuevalidation - 62
How would you prevent duplicate submissions in a Vue form?
formsvue - 63
How would you make a custom text input support v-model?
forms - 64
How would you reset a Vue form after a successful submission?
formsvue - 65
Where would you load initial API data in a Vue Composition API component?
componentscomposition-apivue - 66
How would you display loading, error, empty, and success states for fetched data?
- 67
How would you reload data when a reactive filter changes?
reactreactivity - 68
Rapid search changes return API responses out of order; how would you fix the displayed result?
api - 69
How would you prepare API response data for use by Vue components?
componentsvueapi - 70
How would you connect a parent page and an editable child component?
components - 71
Two sibling Vue components need to share a selected item; how would you connect them?
componentsvue - 72
How would you use provide and inject for a theme shared by a component subtree?
components - 73
An injected reactive object is being changed by many descendants; how would you improve the design?
reactreactivitydesign - 74
Data is passed through five component levels but only the last component uses it; what would you change?
components - 75
How would you let a reusable panel component accept custom header and body content?
components - 76
How would you build a reusable list that lets parents customize each row?
- 77
A route component should load a different user when the route ID changes; how would you implement it?
components - 78
How would you navigate after a Vue form creates a new record?
formsvue - 79
How would you share authenticated user data across several Vue routes?
vue - 80
How would you implement an asynchronous Pinia action that loads products?
state-managementasync - 81
A destructured property from reactive no longer updates the template; how would you fix it?
reactreactivitydestructuring - 82
A ref changes in script but the expected value is not updated; what would you check?
probability - 83
Replacing a reactive object does not update consumers; how would you correct the state model?
reactreactivity - 84
A watcher on state.search never runs when the field changes; how would you fix it?
reactivity - 85
A watcher reacts when an object is replaced but not when a nested field changes; what would you do?
reactreactivity - 86
watchEffect stops reacting to a value read after await; how would you repair it?
reactreactivityasync - 87
A computed value does not update after changing a plain module variable; how would you fix it?
reactivity - 88
Input values appear on the wrong rows after a list is reordered; how would you fix it?
- 89
Vue warns that a prop is readonly when a child edits it; how would you refactor the component?
componentsvuerefactoring - 90
A parent does not receive a custom event from its child; what would you inspect?
- 91
A template ref is null when you try to focus an input; how would you fix it?
componentsfundamentals - 92
How would you read the updated DOM immediately after changing Vue state?
domvue - 93
A component adds duplicate window listeners after being opened several times; how would you fix it?
components - 94
A frequently opened dropdown loses its local state with v-if; what would you change?
components - 95
How would you build a reusable form field that displays its own validation message?
formsvalidation - 96
How would you debounce a Vue search input without leaking timers?
debouncevue - 97
How would you lazy-load a large Vue route or optional component?
componentsvue - 98
How would you protect a Vue Router page that requires authentication?
routingvueauth - 99
How would you make a data-fetching Vue component easier to test?
componentsvue - 100
How would you structure a small Vue dashboard with routes, shared user state, and reusable widgets?
vue