From 4f72e6da8b1db9fa8f3223b6dda90d8414a67828 Mon Sep 17 00:00:00 2001 From: liufangjia Date: Wed, 27 Nov 2024 09:29:24 +0800 Subject: [PATCH] feat: 代码提交 --- src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue | 25 ++++++++++++------------- src/views/basic/askTestQuestion/wrongQuestion.vue | 23 +++++++++++------------ 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue b/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue index fad43b4..486dda0 100644 --- a/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue +++ b/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue @@ -382,19 +382,18 @@ export default { }, onIFrameLoad(id) { const iframeRef = this.$refs["iframe" + id][0]; // 获取对应的 iframe - // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; - // const body = iframeRef.contentWindow.document.body; - // const height = body.scrollHeight; // 获取内容的高度 - // console.log(height, "body高度"); - // iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 - // // 获取第一个P标签 - // const firstP = doc.getElementsByTagName("p")[0]; - // // 或者修改第一个 < p > 标签的内容; - // if (firstP) { - // console.log(firstP, firstP.innerHTML, "-----innerHTML-----"); - // let a = this.processString(firstP.innerHTML); - // firstP.innerHTML = a; - // } + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; + const body = iframeRef.contentWindow.document.body; + const height = body.scrollHeight; // 获取内容的高度 + console.log(height, "body高度"); + iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 + // 获取第一个P标签 + const firstP = doc.getElementsByTagName("p")[0]; + // 或者修改第一个 < p > 标签的内容; + if (firstP) { + let a = this.processString(firstP.innerHTML); + firstP.innerHTML = a; + } }, // 启动编辑模式 diff --git a/src/views/basic/askTestQuestion/wrongQuestion.vue b/src/views/basic/askTestQuestion/wrongQuestion.vue index a92f116..448c716 100644 --- a/src/views/basic/askTestQuestion/wrongQuestion.vue +++ b/src/views/basic/askTestQuestion/wrongQuestion.vue @@ -567,18 +567,17 @@ export default { // 获取ref onIFrameLoad(index) { const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe - // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; - // const body = iframeRef.contentWindow.document.body; - // const height = body.scrollHeight; // 获取内容的高度 - // iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 - // // 获取第一个P标签 - // const firstP = doc.getElementsByTagName("p")[0]; - // // 或者修改第一个 < p > 标签的内容; - // if (firstP) { - // console.log(firstP, firstP.innerHTML, "-----innerHTML-----"); - // let a = this.processString(firstP.innerHTML); - // firstP.innerHTML = a; - // } + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; + const body = iframeRef.contentWindow.document.body; + const height = body.scrollHeight; // 获取内容的高度 + iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 + // 获取第一个P标签 + const firstP = doc.getElementsByTagName("p")[0]; + // 或者修改第一个 < p > 标签的内容; + if (firstP) { + let a = this.processString(firstP.innerHTML); + firstP.innerHTML = a; + } }, // 子集删除后 父级需要更新 -- libgit2 0.21.4