From 5a75f2626ec600b180e357243db4379f298eabb9 Mon Sep 17 00:00:00 2001 From: "liupo.wu" Date: Mon, 30 May 2022 10:01:00 +0800 Subject: [PATCH] fix: ref not id --- src/components/editor/index.vue | 12 +++++--- src/layout/routerView/iframes.vue | 5 ++-- src/views/fun/clipboard/index.vue | 30 +++++++++---------- src/views/fun/countup/index.vue | 19 +++++------- src/views/fun/echartsMap/index.vue | 5 ++-- src/views/fun/printJs/index.vue | 8 +++-- src/views/pages/drag/index.vue | 2 +- .../pages/workflow/component/tool/help.vue | 2 +- src/views/pages/workflow/index.vue | 21 ++++++++----- src/views/visualizing/demo1.vue | 6 ++-- src/views/visualizing/demo2.vue | 5 ++-- 11 files changed, 63 insertions(+), 52 deletions(-) diff --git a/src/components/editor/index.vue b/src/components/editor/index.vue index 55f42053..78e57262 100644 --- a/src/components/editor/index.vue +++ b/src/components/editor/index.vue @@ -1,7 +1,7 @@ @@ -13,6 +13,8 @@ import { toolbarKeys } from './toolbar'; // 定义接口来定义对象的类型 interface WangeditorState { + editorToolbar: HTMLDivElement | null; + editorContent: HTMLDivElement | null; editor: any; } @@ -51,7 +53,9 @@ export default defineComponent({ }, setup(props, { emit }) { const state = reactive({ + editorToolbar: null, editor: null, + editorContent: null, }); // 富文本配置 const wangeditorConfig = () => { @@ -79,13 +83,13 @@ export default defineComponent({ const initWangeditor = () => { state.editor = createEditor({ html: props.modelValue, - selector: `#${props.id}`, + selector: state.editorContent!, config: wangeditorConfig(), mode: props.mode, }); createToolbar({ editor: state.editor, - selector: '#editor-toolbar', + selector: state.editorToolbar!, mode: props.mode, config: toolbarConfig(), }); diff --git a/src/layout/routerView/iframes.vue b/src/layout/routerView/iframes.vue index 91bd347b..43e71c51 100644 --- a/src/layout/routerView/iframes.vue +++ b/src/layout/routerView/iframes.vue @@ -1,6 +1,6 @@ @@ -20,6 +20,7 @@ export default defineComponent({ const { isTagsViewCurrenFull } = storeToRefs(storesTagsViewRoutes); const route = useRoute(); const state = reactive({ + iframeDom: null as HTMLIFrameElement | null, iframeLoading: true, iframeUrl: '', }); @@ -28,7 +29,7 @@ export default defineComponent({ state.iframeUrl = route.meta.isLink; nextTick(() => { state.iframeLoading = true; - const iframe = document.getElementById('iframe'); + const iframe = state.iframeDom; if (!iframe) return false; iframe.onload = () => { state.iframeLoading = false; diff --git a/src/views/fun/clipboard/index.vue b/src/views/fun/clipboard/index.vue index 57edd00c..a92eed01 100644 --- a/src/views/fun/clipboard/index.vue +++ b/src/views/fun/clipboard/index.vue @@ -1,20 +1,18 @@