Provide and inject of vue3 combined api

Preface: In the composition API of Vue 3, `provide` and `inject` are a pair of advanced options for passing data between parent components and child components. They can replace traditional props and event delivery methods, making it easier to share data and methods.

Data transfer:

                provide('unique key value', 'here is the value to be passed')

Data reception:

                const aa = inject('unique key value')

Here we mainly introduce several types of transfer, and go directly to the code.

Guess you like

Origin blog.csdn.net/m0_69097184/article/details/132469085