Understanding Vue 2's Reactivity System

Reactivity Mechanism Vue recursively traverses the object returned by data() and overrides its properties using Object.defineProperty() from ES5 to intercept read and write operations on these properties. For instance, if there's a property called username in data: const originalValue = data.username; Object.defineProperty(data, 'username', { ...

Posted on Wed, 02 Sep 2026 16:16:28 +0000 by dave914

Building a Mini Vue: Implementing Observer, Watcher, and Compiler

Vue's source code implements dependency collection using the Observer pattern. It involves three main classes: Dep: Acts as the observable target. Every data property has a Dep instance containing a subs queue (short for subscribers) that holds all Watcher instances depending on the data. When data changes, dep.notify() is called to inform all ...

Posted on Mon, 24 Aug 2026 16:25:35 +0000 by rcoursey

Resolving UI State Desynchronization After Data Deletion in Vue 3 Projects

Developers frequently encounter scenarios where an asynchronous delete operation completes successfully at the server level, yet the associated frontend data table fails to reflect these changes. This discrepancy usually points to missed refresh callbacks or improper handling of reactivity within the component setup phase. In complex setups inv ...

Posted on Thu, 20 Aug 2026 16:12:29 +0000 by Encrypt

Vue 3 Fundamentals

Enviroment Setup Vue 3 requires Node.js for development. Install the Vue CLI globally: npm install -g @vue/cli vue --version # Verify version (≥4.5.0) vue create project-name # Select "Manually select features" during setup Composition API Fundamentals Reactive State Management ref() for Primitive Values <template> <div&g ...

Posted on Sat, 01 Aug 2026 16:18:24 +0000 by tiki

Understanding ref and Template Refs in Vue 3 with Migration from Vue 2

Vue 3 introduces distinct concepts of ref for reactivity and template refs for accessing DOM elements or component instances. ref: Reactive References ref creates reactive data references in Composition API. Basic Usage import { ref } from 'vue' const counter = ref(0) console.log(counter.value) // Output: 0 counter.value++ console.log(counter ...

Posted on Thu, 30 Jul 2026 16:24:34 +0000 by tyson

Vue 3 vs Vue 2: Key Differences and Development Impacts

Core Improvements in Vue 3 Performance Enhancements: Virtual DOM rewritten with static node skipping and dynamic node-only processing. Update performence improved by 1.3-2x, and SSR speed increased 2-3x. Tree-shaking Support: Removes unused modules during build. Based on static analysis of ES6 imports to identify and eliminate unused code. Fra ...

Posted on Sun, 26 Jul 2026 16:30:24 +0000 by PHPdev

Deep Watch and Immediate Callback Execution in Vue.js

Basic Watch Usage For a list page that requires automatic search when users input keywords, you can use watch to monitor search value changes instead of relying solely on input change events. <template> <div> <div class="search-container"> <label>Search</label> <input v-model="qu ...

Posted on Tue, 07 Jul 2026 17:05:37 +0000 by poelinca

Vue.js Core Concepts and Practical Implementation

To install Vue CLI globally: npm install -g @vue/cli npm install -g @vue/cli-init Creating a new project: vue create project-name cd project-name npm run serve Template Fundamentals Basic template syntax includes: Text interpolation: {{ variable }} v-once: One-time rendering v-html: HTML rendering v-bind: Attribute binding (shorthand ':') Co ...

Posted on Sun, 05 Jul 2026 16:45:04 +0000 by KFC

Why Vue Doesn't Make Array Index Assignment Reactive via Object.defineProperty

Object.defineProperty can indeed observe array elements. For example, you can iterate over an array and define getter/setter for each index: let array = [1, 2, 3, 4, 5]; array.forEach((item, index) => { defineReactive(array, index, item); }); function defineReactive(obj, key, val) { Object.defineProperty(obj, key, { enumerab ...

Posted on Sat, 20 Jun 2026 17:46:28 +0000 by klainis

Reactive Side-Effects with Vue 3 Watchers

Vue 3’s watch API lets you run arbitrary code whenever a reactive value changes. Its the reactive system’s hook for side-effects—loggging, validation, network requests, or synchronizing related state. Listening to a single ref <template> <p>Counter: {{ count }}</p> <button @click="count++">Increment</but ...

Posted on Wed, 03 Jun 2026 17:54:37 +0000 by pingu