What is the Options API?
The Options API is the traditional way of writing components in Vue (it was the default in Vue 2 and is still available in Vue 3). In this approach, all of a component's logic is split across options:
datamethodscomputedwatchpropsmounted,created, and other hookscomponentsfilters(in Vue 2)- and so on
In simple terms:
The Options API is a way of declaring a component where each type of logic goes into its own block.
Example component using the Options API
<script>
export default {
data() {
return {
counter: 0
}
},
computed: {
double() {
return this.counter * 2
}
},
methods: {
increment() {
this.counter++
}
},
mounted() {
console.log("Component mounted")
}
}
</script>
<template>
<button @click="increment">Count: {{ counter }} (x2: {{ double }})</button>
</template>The core idea of the Options API
All of a component's code is split by type, not by functionality:
data()holds only the datamethodsholds the methodscomputedholds the computed propertieswatchholds the watchersmountedholds the code that runs on mount
This is convenient for simple components, but in large ones the logic belonging to one functional block ends up scattered across the file.
Advantages of the Options API
Good for beginners
The logic is structured "into its own shelves".
Great for small components
A simple, clear, and readable approach.
Easy to read when the component is small
Because everything is where you expect it to be.
Compatible with Vue 3
The Options API is fully supported in Vue 3.
Disadvantages of the Options API (why the Composition API was invented)
Logic gets smeared across different sections
As a component grows, working with it gets harder.
Poorly suited to reusing logic
You had to use mixins, which brought:
- name conflicts
- hidden magic
- poor readability
Harder to organize complex components
You need to jump around the file between data/methods/computed/watch/mounted…
Summary (great for an interview)
The Options API is the classic way of describing components in Vue, using an object with options (
data,methods,computed,watch, etc.). Easy to learn, convenient for small components, fully supported in Vue 3, but scales poorly, which is why the more flexible Composition API appeared.
If you want, I can give a comparison of the Options API vs the Composition API, or explain when each approach is best to use.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.