Vue Options API
Use this skill for Vue projects written in Options API style.
For new Vue 3 projects, prefer the vue skill (Composition API with <script setup>).
Core
| Topic |
Description |
Reference |
| State: data, computed, methods, watch |
Reactive state, derived values, event handlers, side effects |
state |
| Props & Emits |
Receiving data from parent, emitting events to parent |
props-emits |
| Lifecycle Hooks |
Component creation, mounting, updating, unmounting |
lifecycle |
Features
| Topic |
Description |
Reference |
| provide / inject |
Dependency injection across deep component trees |
provide-inject |
| Mixins |
Reusable logic shared across components (use with caution) |
mixins |
Quick Reference
Full SFC Template
<script>
export default {
name: 'MyComponent',
props: {
title: {
type: String,
required: true
},
count: {
type: Number,
default: 0
}
},
emits: ['update'],
data() {
return {
localCount: this.count
}
},
computed: {
doubled() {
return this.localCount * 2
}
},
watch: {
count(newVal) {
this.localCount = newVal
}
},
methods: {
increment() {
this.localCount++
this.$emit('update', this.localCount)
}
},
mounted() {
console.log('Component mounted')
}
}
</script>
<template>
<div>
<h1>{{ title }}</h1>
<p>Count: {{ localCount }} | Doubled: {{ doubled }}</p>
<button @click="increment">Increment</button>
</div>
</template>
Key Rules
data must be a function (not an object) to avoid shared state across instances.
computed properties are cached — only recompute when dependencies change.
- Use
watch for side effects (API calls, logging), not for deriving state.
- Declare all
emits explicitly to document the component's contract.
- Avoid
mixins in new code — prefer composables (Composition API) for reuse.
Source: vuluu2k/skills — distributed by TomeVault.
1---2name: vue-options3description: Vue 3 Options API — data, props, computed, methods, watch, emits, provide/inject, lifecycle hooks, and mixins. Use when the project uses Options API style (Vue 2 legacy or explicit Vue 3 Options API preference). Use when this capability is needed.4---56# Vue Options API78> Use this skill for Vue projects written in **Options API** style.9> For new Vue 3 projects, prefer the `vue` skill (Composition API with `<script setup>`).1011## Core1213| Topic | Description | Reference |14|-------|-------------|-----------|15| State: data, computed, methods, watch | Reactive state, derived values, event handlers, side effects | [state](references/state.md) |16| Props & Emits | Receiving data from parent, emitting events to parent | [props-emits](references/props-emits.md) |17| Lifecycle Hooks | Component creation, mounting, updating, unmounting | [lifecycle](references/lifecycle.md) |1819## Features2021| Topic | Description | Reference |22|-------|-------------|-----------|23| provide / inject | Dependency injection across deep component trees | [provide-inject](references/provide-inject.md) |24| Mixins | Reusable logic shared across components (use with caution) | [mixins](references/mixins.md) |2526## Quick Reference2728### Full SFC Template2930```vue31<script>32export default {33 name: 'MyComponent',3435 props: {36 title: {37 type: String,38 required: true39 },40 count: {41 type: Number,42 default: 043 }44 },4546 emits: ['update'],4748 data() {49 return {50 localCount: this.count51 }52 },5354 computed: {55 doubled() {56 return this.localCount * 257 }58 },5960 watch: {61 count(newVal) {62 this.localCount = newVal63 }64 },6566 methods: {67 increment() {68 this.localCount++69 this.$emit('update', this.localCount)70 }71 },7273 mounted() {74 console.log('Component mounted')75 }76}77</script>7879<template>80 <div>81 <h1>{{ title }}</h1>82 <p>Count: {{ localCount }} | Doubled: {{ doubled }}</p>83 <button @click="increment">Increment</button>84 </div>85</template>86```8788### Key Rules8990- `data` must be a **function** (not an object) to avoid shared state across instances.91- `computed` properties are **cached** — only recompute when dependencies change.92- Use `watch` for **side effects** (API calls, logging), not for deriving state.93- Declare all `emits` explicitly to document the component's contract.94- Avoid `mixins` in new code — prefer composables (Composition API) for reuse.9596---97> Source: [vuluu2k/skills](https://github.com/vuluu2k/skills) — distributed by [TomeVault](https://tomevault.io).98<!-- tomevault:4.0:skill_md:2026-04-19 -->