first commit
This commit is contained in:
13
src/utils/useCurrentInstance.ts
Normal file
13
src/utils/useCurrentInstance.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { getCurrentInstance } from 'vue'
|
||||
import type { ComponentInternalInstance } from 'vue'
|
||||
|
||||
export default function useCurrentInstance() {
|
||||
if (!getCurrentInstance()) {
|
||||
throw new Error('useCurrentInstance() can only be used inside setup() or functional components!')
|
||||
}
|
||||
const { appContext } = getCurrentInstance() as ComponentInternalInstance
|
||||
const proxy = appContext.config.globalProperties
|
||||
return {
|
||||
proxy,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user