provide / inject cho phép truyền data qua component tree mà không cần props drilling.
Parent provide, bất kỳ descendant nào có thể inject:
javascript
// Parent
import { provide, ref } from 'vue'
const theme = ref('dark')
provide('theme', theme)
// Child (bất kỳ cấp)
import { inject } from 'vue'
const theme = inject('theme', 'light') // 'light' là defaultDùng khi:
- Shared state cho subtree (theme, locale, auth)
- Plugin/library cung cấp context
Pitfall: khó debug hơn props vì data flow không explicit — dùng Symbol key để tránh naming collision.