mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-02-03 02:54:40 +08:00
fix(markdown): set value
error
修复markdown组件在完成初始化之前动态设置value可能导致异常的问题
This commit is contained in:
parent
d95815b503
commit
35e1347029
@ -59,8 +59,8 @@
|
|||||||
(v) => {
|
(v) => {
|
||||||
if (v !== valueRef.value) {
|
if (v !== valueRef.value) {
|
||||||
instance.getVditor()?.setValue(v);
|
instance.getVditor()?.setValue(v);
|
||||||
valueRef.value = v;
|
|
||||||
}
|
}
|
||||||
|
valueRef.value = v;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -85,7 +85,7 @@
|
|||||||
const wrapEl = unref(wrapRef) as HTMLElement;
|
const wrapEl = unref(wrapRef) as HTMLElement;
|
||||||
if (!wrapEl) return;
|
if (!wrapEl) return;
|
||||||
const bindValue = { ...attrs, ...props };
|
const bindValue = { ...attrs, ...props };
|
||||||
vditorRef.value = new Vditor(wrapEl, {
|
const insEditor = new Vditor(wrapEl, {
|
||||||
theme: getDarkMode.value === 'dark' ? 'dark' : 'classic',
|
theme: getDarkMode.value === 'dark' ? 'dark' : 'classic',
|
||||||
lang: unref(getCurrentLang),
|
lang: unref(getCurrentLang),
|
||||||
mode: 'sv',
|
mode: 'sv',
|
||||||
@ -100,7 +100,10 @@
|
|||||||
after: () => {
|
after: () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
modalFn?.redoModalHeight?.();
|
modalFn?.redoModalHeight?.();
|
||||||
|
insEditor.setValue(valueRef.value);
|
||||||
|
vditorRef.value = insEditor;
|
||||||
initedRef.value = true;
|
initedRef.value = true;
|
||||||
|
emit('get', instance);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
blur: () => {
|
blur: () => {
|
||||||
@ -124,14 +127,10 @@
|
|||||||
vditorInstance?.destroy?.();
|
vditorInstance?.destroy?.();
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
vditorRef.value = null;
|
vditorRef.value = null;
|
||||||
|
initedRef.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMountedOrActivated(() => {
|
onMountedOrActivated(init);
|
||||||
nextTick(() => {
|
|
||||||
init();
|
|
||||||
});
|
|
||||||
emit('get', instance);
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(destroy);
|
onBeforeUnmount(destroy);
|
||||||
onDeactivated(destroy);
|
onDeactivated(destroy);
|
||||||
|
Loading…
Reference in New Issue
Block a user