← ClaudeAtlas

dhpk-vue-2-noteslisted

Vue 2 (^2.5.17, Options API era) component structure and the reactivity caveats that bite when mutating reactive state. Use when writing or reviewing .vue single-file components in a Vue 2 project (resources/assets/js), or a codebase whose package.json pins vue ^2.5.x. Covers the data() / computed / methods / watch + lifecycle shape, props-down + $emit events-up, vue-loader SFC compilation, the Vue.set / array-mutation traps, and @vue/test-utils 1.x + vue-jest 3 testing. Not for Vue 3 or 2.7 Composition API (predates setup() / <script setup>) — load when touching components or planning a Vue 2 → 3 migration. Output: Vue 2 component guidance, migration traps, and verification gates.
hmj1026/dhpk · ★ 2 · Web & Frontend · score 71
Install: claude install-skill hmj1026/dhpk
# Vue 2 — Options API baseline Targets `vue ^2.5.17`. **Options API only** — the Composition API (`setup()`, `ref`, `reactive`, `<script setup>`) does not exist here; it arrives in 2.7 as a backport and is the default in Vue 3. > SFCs (`.vue`) are compiled by `vue-loader` driven by Laravel Mix > (webpack 4). Source lives under `resources/assets/js`. See the > `laravel` family skill's `mix` selector for the build wiring. --- ## Signature features ### Options API component structure ```js export default { name: 'OrderTicket', props: { order: { type: Object, required: true }, compact: { type: Boolean, default: false }, }, // data MUST be a function returning a fresh object, so each // component instance gets its own state (not a shared reference). data() { return { expanded: false, note: '', }; }, computed: { // cached, re-evaluated only when a reactive dependency changes title() { return this.compact ? this.order.no : this.order.fullName; }, }, methods: { toggle() { this.expanded = !this.expanded; }, }, watch: { // imperative side effects on a value change 'order.status'(next, prev) { if (next === '6') this.$emit('done', this.order.id); }, }, created() { // instance + reactivity ready; DOM NOT yet mounted }, mounted() { // DOM availa