1. What is the v-model modifier .lazy?
Intermediate<input v-model.lazy="msg">
Answer: Syncs on change event instead of input
.lazy makes v-model sync on change event (after blur) instead of input. Other modifiers: .number (parse as number), .trim (trim whitespace).
2. How do you emit custom events from a child component?
Beginnerthis.$emit("eventName", data)
Answer: This is correct for Options API
$emit emits custom events to parent. First argument is event name, subsequent arguments are passed data. Parent listens with @eventName.
3. How do you prevent default form submission?
Beginner@submit.prevent="handleSubmit"
Answer: This is correct (event modifier)
Event modifiers like .prevent are postfixes added to directives. @submit.prevent calls event.preventDefault() automatically.
4. What is the correct way to create a Vue instance?
Beginnerconst app = Vue.createApp({})
Answer: This is correct for Vue 3
Vue 3 uses createApp() to create application instances. Vue 2 used new Vue(). The new API allows multiple app instances.
5. How do you bind an attribute in Vue?
Beginner<img v-bind:src="imageUrl">
Answer: Both a and c
v-bind:attribute binds data to attributes. The shorthand is :attribute. Both syntaxes are valid.
6. How do you handle button clicks in Vue?
Beginner<button @click="handleClick">Click</button>
Answer: This is correct
Use @click (or v-on:click) to handle click events. Pass a method name or inline expression.
7. How do you interpolate text in Vue templates?
BeginnerAnswer: This is correct (mustache syntax)
Double curly braces {{ }} (mustache syntax) interpolate data into text. v-text directive is an alternative.
8. How do you register a global component?
Beginnerapp.component("my-component", {})
Answer: This is correct
app.component() registers components globally in Vue 3. Components must be registered before createApp().mount().
9. How do you mount a Vue app to the DOM?
BeginnerAnswer: This is correct
mount() attaches the Vue app to a DOM element. Pass a CSS selector or DOM element. Returns root component instance.
10. What is the Composition API?
IntermediateAnswer: Alternative API for composing component logic with functions
Composition API uses composition functions (composables) instead of options. Better TypeScript support, more flexible code reuse. Vue 3 feature.
11. What is the Vue reactivity system based on?
AdvancedAnswer: Proxies in Vue 3, Object.defineProperty in Vue 2
Vue 3 uses ES6 Proxies for reactivity (better performance, no caveats). Vue 2 used Object.defineProperty (limitations with arrays, new properties).
12. What are the limitations of Vue 2 reactivity?
AdvancedAnswer: Cannot detect property addition/deletion or array indices
Vue 2 cannot detect property addition/deletion or direct array index modification. Use Vue.set() or array methods. Vue 3 has no such limitations.
13. What is the setup() function?
IntermediateAnswer: Entry point for Composition API
setup() is the Composition API entry point. Runs before component is created. Returns values exposed to template. Runs only once.
14. What does ref() do in Vue 3?
IntermediateAnswer: Creates a reactive reference to a value
ref() wraps a value in a reactive object. Access/modify via .value in script. Auto-unwrapped in templates. Use for primitives.
15. What is the purpose of shallowRef()?
AdvancedAnswer: Creates ref with shallow reactivity (only .value is reactive)
shallowRef() creates ref where only .value assignment is reactive. Nested properties are not reactive. Performance optimization for large objects.
16. What does reactive() do in Vue 3?
IntermediateAnswer: Makes an object deeply reactive
reactive() creates a deeply reactive proxy of an object. Unlike ref, properties are accessed directly. Use for objects/arrays.
17. What is the purpose of shallowReactive()?
AdvancedAnswer: Creates reactive object with only root-level reactivity
shallowReactive() creates reactive object where only root-level properties are reactive. Nested objects are not. Performance optimization.
18. What is the difference between ref() and reactive()?
IntermediateAnswer: ref for primitives (needs .value), reactive for objects
ref works with primitives and objects (requires .value). reactive only works with objects. ref auto-unwraps in templates.
19. What is readonly()?
AdvancedAnswer: Creates readonly proxy of object
readonly() creates read-only proxy. Mutations warn in development. Nested objects also readonly (deep). Use shallowReadonly() for shallow.
20. What are computed properties?
IntermediateAnswer: Cached reactive values based on dependencies
Computed properties are cached based on dependencies. Only re-compute when dependencies change. Use computed() in Composition API.
21. What is toRaw()?
AdvancedAnswer: Returns raw object from reactive proxy
toRaw() returns the original object from reactive proxy. Use for temporary operations without triggering effects. Changes still tracked normally.
22. What directive is used to conditionally render elements?
BeginnerAnswer: Both a and b
Both v-if and v-show conditionally render elements. v-if removes from DOM, v-show toggles CSS display. Use v-show for frequent toggles.
23. What is markRaw()?
AdvancedAnswer: Marks object to never be reactive
markRaw() marks object to skip reactive conversion. Useful for large immutable data structures, third-party class instances. Performance optimization.
24. What is the difference between v-if and v-show?
BeginnerAnswer: v-if removes from DOM, v-show uses CSS display
v-if conditionally renders (adds/removes from DOM). v-show always renders but toggles CSS display. v-show has cheaper toggle cost.
Ready to test yourself?
The full Vue.js bank has 90 questions across 3 difficulty levels — timed, shuffled, and scored.
Take the Vue.js quiz