vue-class-di
Advanced tools
Comparing version 1.2.3 to 1.2.4
{ | ||
"name": "vue-class-di", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.ts", |
@@ -106,2 +106,10 @@ import { defineComponent, getCurrentInstance, h, inject, InjectionKey, provide } from 'vue-demi' | ||
for (const key in Component) { | ||
if (Object.prototype.hasOwnProperty.call(Component, key)) { | ||
const element = Component[key] | ||
//@ts-ignore | ||
Extended[key] ||= element | ||
} | ||
} | ||
return Extended as any | ||
@@ -215,3 +223,2 @@ } | ||
/** | ||
@@ -223,13 +230,13 @@ * 从当前容器中获取服务 | ||
export function injectService<T extends { new (...args: any[]): any }>( | ||
token: T, | ||
notFoundValue?: any | ||
token: T, | ||
notFoundValue?: any | ||
): InstanceType<T> | undefined | ||
export function injectService<T>( | ||
token: string | number | symbol, | ||
notFoundValue?: any | ||
token: string | number | symbol, | ||
notFoundValue?: any | ||
): T | undefined { | ||
const currentInjector = getCurrentInjector() | ||
if (!currentInjector) return notFoundValue | ||
const currentInjector = getCurrentInjector() | ||
if (!currentInjector) return notFoundValue | ||
return currentInjector.get(token, notFoundValue) | ||
return currentInjector.get(token, notFoundValue) | ||
} |
24165
681