一、基础
Provide + inject 主要用于父子组件之间的数据使用(孙组件用爷组件的数据)
爷组件
import { provide, ref } from '@vue/runtime-core'const str = ref('爷组件的数据')provide("str", str);
父组件 ```typescript import { inject, Ref } from “vue”;
const str:Ref
- 子组件```typescriptimport { Ref } from "vue"import { inject } from "@vue/runtime-core";const str: Ref<string> = inject("str")
- 结果展示

