Trung BìnhVue.js iconVue.js

Reactivity system trong Vue 3 hoạt động thế nào?

Vue 3 dùng ES6 Proxy để intercept get/set operations trên reactive objects.

Khi đọc property trong effect (computed, watcher, render): dependency được track.

Khi set property: trigger cập nhật tất cả dependents.

Cải tiến so với Vue 2 (dùng Object.defineProperty):

  1. Detect thêm/xóa property động
  2. Detect array index changes và .length
  3. Lazy — không cần walk toàn bộ object tree upfront

Xem toàn bộ Vue.js cùng filter theo level & chủ đề con.

Mở danh sách Vue.js