provideinject
Provide/inject is a dependency injection mechanism in Vue.js that lets an ancestor component provide data or services to descendant components without passing props through every intermediate component. It is commonly used for sharing global resources such as themes, localization, or plugin utilities across a component subtree.
In Vue 2, a component can declare provide either as an object or as a function returning
provide: {
}
inject: ['theme', 'apiClient']
inject: {
theme: { from: 'theme', default: 'light' },
locale: { from: 'locale', default: 'en' }
}
In Vue 2, provided values are not reactive by default; to share reactive state, provide a reactive
Provide/inject operates along the component hierarchy and is not intended as a general event bus or