mirror of https://github.com/vuejs/core.git
parent
1fbfa6962b
commit
321d80758c
|
@ -2,6 +2,7 @@ import {
|
||||||
type InjectionKey,
|
type InjectionKey,
|
||||||
type Ref,
|
type Ref,
|
||||||
createApp,
|
createApp,
|
||||||
|
defineComponent,
|
||||||
inject,
|
inject,
|
||||||
provide,
|
provide,
|
||||||
ref,
|
ref,
|
||||||
|
@ -52,3 +53,9 @@ provide<Cube>(123, { size: 'foo' })
|
||||||
const app = createApp({})
|
const app = createApp({})
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
app.provide(injectionKeyRef, ref({}))
|
app.provide(injectionKeyRef, ref({}))
|
||||||
|
|
||||||
|
defineComponent({
|
||||||
|
provide: {
|
||||||
|
[injectionKeyRef]: { size: 'foo' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
|
@ -4,7 +4,9 @@ import { currentRenderingInstance } from './componentRenderContext'
|
||||||
import { currentApp } from './apiCreateApp'
|
import { currentApp } from './apiCreateApp'
|
||||||
import { warn } from './warning'
|
import { warn } from './warning'
|
||||||
|
|
||||||
export interface InjectionKey<T> extends Symbol {}
|
interface InjectionConstraint<T> {}
|
||||||
|
|
||||||
|
export type InjectionKey<T> = symbol & InjectionConstraint<T>
|
||||||
|
|
||||||
export function provide<T, K = InjectionKey<T> | string | number>(
|
export function provide<T, K = InjectionKey<T> | string | number>(
|
||||||
key: K,
|
key: K,
|
||||||
|
|
Loading…
Reference in New Issue