Skip to content

Commit

Permalink
chore(vue): instance alert
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed May 18, 2023
1 parent 602ed5f commit 36b8940
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/vue/src/use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import pdfeasy from 'pdfeasy';
import { getCurrentInstance, ComponentInternalInstance } from 'vue-demi';

export const usePDF = (): typeof pdfeasy => {
const internalInstance = getCurrentInstance()
const pdf = (internalInstance as ComponentInternalInstance).appContext
const instance = getCurrentInstance();

if (!instance) {
console.warn(
"[VUE-PDFEASY] - Vue instance not exists. Hook is in setup() context?"
);
}

const pdf = (instance as ComponentInternalInstance).appContext
.config.globalProperties.$pdf

return pdf
Expand Down

0 comments on commit 36b8940

Please sign in to comment.