mirror of
https://github.com/mathuo/dockview
synced 2025-01-23 09:55:58 +00:00
Merge pull request #625 from mathuo/624-dockview-vue-error-cannot-read-properties-of-null-reading-appcontext
bug: vue getInstance
This commit is contained in:
commit
82dbdb29c3
@ -70,55 +70,61 @@ PROPERTY_KEYS.forEach((coreOptionKey) => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!el.value) {
|
if (!el.value) {
|
||||||
throw new Error('element is not mounted');
|
throw new Error('dockview-vue: element is not mounted');
|
||||||
|
}
|
||||||
|
|
||||||
|
const inst = getCurrentInstance();
|
||||||
|
|
||||||
|
if(!inst) {
|
||||||
|
throw new Error('dockview-vue: getCurrentInstance() returned null')
|
||||||
}
|
}
|
||||||
|
|
||||||
const frameworkOptions: DockviewFrameworkOptions = {
|
const frameworkOptions: DockviewFrameworkOptions = {
|
||||||
parentElement: el.value,
|
parentElement: el.value,
|
||||||
createComponent(options) {
|
createComponent(options) {
|
||||||
const component = findComponent(
|
const component = findComponent(
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
options.name
|
options.name
|
||||||
);
|
);
|
||||||
return new VueRenderer(component!, getCurrentInstance()!);
|
return new VueRenderer(component!, inst);
|
||||||
},
|
},
|
||||||
createTabComponent(options) {
|
createTabComponent(options) {
|
||||||
let component = findComponent(getCurrentInstance()!, options.name);
|
let component = findComponent(inst, options.name);
|
||||||
|
|
||||||
if (!component && props.defaultTabComponent) {
|
if (!component && props.defaultTabComponent) {
|
||||||
component = findComponent(
|
component = findComponent(
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
props.defaultTabComponent
|
props.defaultTabComponent
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component) {
|
if (component) {
|
||||||
return new VueRenderer(component, getCurrentInstance()!);
|
return new VueRenderer(component, inst);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
createWatermarkComponent: props.watermarkComponent
|
createWatermarkComponent: props.watermarkComponent
|
||||||
? () => {
|
? () => {
|
||||||
const component = findComponent(
|
const component = findComponent(
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
props.watermarkComponent!
|
props.watermarkComponent!
|
||||||
);
|
);
|
||||||
|
|
||||||
return new VueWatermarkRenderer(
|
return new VueWatermarkRenderer(
|
||||||
component!,
|
component!,
|
||||||
getCurrentInstance()!
|
inst
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
createLeftHeaderActionComponent: props.leftHeaderActionsComponent
|
createLeftHeaderActionComponent: props.leftHeaderActionsComponent
|
||||||
? (group) => {
|
? (group) => {
|
||||||
const component = findComponent(
|
const component = findComponent(
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
props.leftHeaderActionsComponent!
|
props.leftHeaderActionsComponent!
|
||||||
);
|
);
|
||||||
return new VueHeaderActionsRenderer(
|
return new VueHeaderActionsRenderer(
|
||||||
component!,
|
component!,
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
group
|
group
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -126,12 +132,12 @@ onMounted(() => {
|
|||||||
createPrefixHeaderActionComponent: props.prefixHeaderActionsComponent
|
createPrefixHeaderActionComponent: props.prefixHeaderActionsComponent
|
||||||
? (group) => {
|
? (group) => {
|
||||||
const component = findComponent(
|
const component = findComponent(
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
props.prefixHeaderActionsComponent!
|
props.prefixHeaderActionsComponent!
|
||||||
);
|
);
|
||||||
return new VueHeaderActionsRenderer(
|
return new VueHeaderActionsRenderer(
|
||||||
component!,
|
component!,
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
group
|
group
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -139,12 +145,12 @@ onMounted(() => {
|
|||||||
createRightHeaderActionComponent: props.rightHeaderActionsComponent
|
createRightHeaderActionComponent: props.rightHeaderActionsComponent
|
||||||
? (group) => {
|
? (group) => {
|
||||||
const component = findComponent(
|
const component = findComponent(
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
props.rightHeaderActionsComponent!
|
props.rightHeaderActionsComponent!
|
||||||
);
|
);
|
||||||
return new VueHeaderActionsRenderer(
|
return new VueHeaderActionsRenderer(
|
||||||
component!,
|
component!,
|
||||||
getCurrentInstance()!,
|
inst,
|
||||||
group
|
group
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user