Counter: {{ count }}
{{ user.email }}
Theme: {{ user.preferences.theme }}
{{ productCount }} products - Total: ${{ totalValue }}
First name: {{ firstName }}
Last name: {{ lastName }}
``` ## Watcher ด้วย watch และ watchEffect Watcher ทำหน้าที่รัน side effect เพื่อตอบสนองต่อการเปลี่ยนแปลงของข้อมูล Vue 3 มีสองแนวทาง: `watch` สำหรับการควบคุมที่แม่นยำ และ `watchEffect` สำหรับการติดตามอัตโนมัติ > **เมื่อไหร่ควรใช้ watch และเมื่อไหร่ควรใช้ watchEffect?** > > `watch` ให้การควบคุม dependency ที่แม่นยำและให้ทั้งค่าเก่าและค่าใหม่ `watchEffect` เหมาะกว่าเมื่อ dependency แบบ reactive ทั้งหมดที่ใช้ควรทริกเอฟเฟกต์ ```javascript // SearchComponent.vueLoading...
Loading users...
Error: {{ error }}
Window width: {{ windowWidth }}px
DOM updates: {{ updateCount }}
Count: {{ count }}
Current theme: {{ theme }}