diff --git a/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue b/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue index 3375fcb..22f77ba 100644 --- a/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue +++ b/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue @@ -431,19 +431,19 @@ 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; - // body.style.overflowX = "hidden"; // 不允许出现横向滚动条 - // const height = body.offsetHeight; // 获取内容的高度 - // iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 - // // 获取第一个P标签 - // const firstP = doc.getElementsByTagName("p")[0]; - // // 或者修改第一个 < p > 标签的内容; - // if (firstP) { - // let a = this.processString(firstP.innerHTML); - // firstP.innerHTML = a; - // } + const iframeRef = this.$refs["iframe" + id][0]; // 获取对应的 iframe + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; + const body = iframeRef.contentWindow.document.body; + body.style.overflowX = "hidden"; // 不允许出现横向滚动条 + const height = body.offsetHeight; // 获取内容的高度 + iframeRef.style.height = `${height + 20}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 19a9534..fcd9b1b 100644 --- a/src/views/basic/askTestQuestion/wrongQuestion.vue +++ b/src/views/basic/askTestQuestion/wrongQuestion.vue @@ -625,22 +625,22 @@ 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; - // body.style.overflowX = "hidden"; // 不允许出现横向滚动条 - // const height = body.offsetHeight; // 获取内容的高度 - // // console.log("body.offsetHeight:", body.offsetHeight); - // // console.log("body.clientHeight:", body.clientHeight); - // // console.log("body.scrollHeight:", body.scrollHeight); - // iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 - // // 获取第一个P标签 - // const firstP = doc.getElementsByTagName("p")[0]; - // // 或者修改第一个 < p > 标签的内容; - // if (firstP) { - // let a = this.processString(firstP.innerHTML); - // firstP.innerHTML = a; - // } + const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; + const body = iframeRef.contentWindow.document.body; + body.style.overflowX = "hidden"; // 不允许出现横向滚动条 + const height = body.offsetHeight; // 获取内容的高度 + // console.log("body.offsetHeight:", body.offsetHeight); + // console.log("body.clientHeight:", body.clientHeight); + // console.log("body.scrollHeight:", body.scrollHeight); + iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 + // 获取第一个P标签 + const firstP = doc.getElementsByTagName("p")[0]; + // 或者修改第一个 < p > 标签的内容; + if (firstP) { + let a = this.processString(firstP.innerHTML); + firstP.innerHTML = a; + } }, // 子集删除后 父级需要更新