[Vue + TS] Use Dependency Injection in Vue Using @Inject and @Provide Decorators with TypeScript

Vue 2.2 introduced a simple dependency injection system, allowing you to use provide and inject in your component options. This lesson shows you how to use them using the @Inject and @Provide decorators in tandem!

 

When you want to provide some service or data from parent to child component you can use @Provide and @Inject.

 

Parent component:



 

Child:



 

转载于:https://www.cnblogs.com/Answer1215/p/7522484.html

你可能感兴趣的:([Vue + TS] Use Dependency Injection in Vue Using @Inject and @Provide Decorators with TypeScript)