Commit 4f72e6da8b1db9fa8f3223b6dda90d8414a67828
1 parent
eed6f068
feat: 代码提交
Showing
2 changed files
with
23 additions
and
25 deletions
src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue
| ... | ... | @@ -382,19 +382,18 @@ export default { |
| 382 | 382 | }, |
| 383 | 383 | onIFrameLoad(id) { |
| 384 | 384 | const iframeRef = this.$refs["iframe" + id][0]; // 获取对应的 iframe |
| 385 | - // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
| 386 | - // const body = iframeRef.contentWindow.document.body; | |
| 387 | - // const height = body.scrollHeight; // 获取内容的高度 | |
| 388 | - // console.log(height, "body高度"); | |
| 389 | - // iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 | |
| 390 | - // // 获取第一个P标签 | |
| 391 | - // const firstP = doc.getElementsByTagName("p")[0]; | |
| 392 | - // // 或者修改第一个 < p > 标签的内容; | |
| 393 | - // if (firstP) { | |
| 394 | - // console.log(firstP, firstP.innerHTML, "-----innerHTML-----"); | |
| 395 | - // let a = this.processString(firstP.innerHTML); | |
| 396 | - // firstP.innerHTML = a; | |
| 397 | - // } | |
| 385 | + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
| 386 | + const body = iframeRef.contentWindow.document.body; | |
| 387 | + const height = body.scrollHeight; // 获取内容的高度 | |
| 388 | + console.log(height, "body高度"); | |
| 389 | + iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 | |
| 390 | + // 获取第一个P标签 | |
| 391 | + const firstP = doc.getElementsByTagName("p")[0]; | |
| 392 | + // 或者修改第一个 < p > 标签的内容; | |
| 393 | + if (firstP) { | |
| 394 | + let a = this.processString(firstP.innerHTML); | |
| 395 | + firstP.innerHTML = a; | |
| 396 | + } | |
| 398 | 397 | }, |
| 399 | 398 | |
| 400 | 399 | // 启动编辑模式 | ... | ... |
src/views/basic/askTestQuestion/wrongQuestion.vue
| ... | ... | @@ -567,18 +567,17 @@ export default { |
| 567 | 567 | // 获取ref |
| 568 | 568 | onIFrameLoad(index) { |
| 569 | 569 | const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe |
| 570 | - // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
| 571 | - // const body = iframeRef.contentWindow.document.body; | |
| 572 | - // const height = body.scrollHeight; // 获取内容的高度 | |
| 573 | - // iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 | |
| 574 | - // // 获取第一个P标签 | |
| 575 | - // const firstP = doc.getElementsByTagName("p")[0]; | |
| 576 | - // // 或者修改第一个 < p > 标签的内容; | |
| 577 | - // if (firstP) { | |
| 578 | - // console.log(firstP, firstP.innerHTML, "-----innerHTML-----"); | |
| 579 | - // let a = this.processString(firstP.innerHTML); | |
| 580 | - // firstP.innerHTML = a; | |
| 581 | - // } | |
| 570 | + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
| 571 | + const body = iframeRef.contentWindow.document.body; | |
| 572 | + const height = body.scrollHeight; // 获取内容的高度 | |
| 573 | + iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 | |
| 574 | + // 获取第一个P标签 | |
| 575 | + const firstP = doc.getElementsByTagName("p")[0]; | |
| 576 | + // 或者修改第一个 < p > 标签的内容; | |
| 577 | + if (firstP) { | |
| 578 | + let a = this.processString(firstP.innerHTML); | |
| 579 | + firstP.innerHTML = a; | |
| 580 | + } | |
| 582 | 581 | }, |
| 583 | 582 | |
| 584 | 583 | // 子集删除后 父级需要更新 | ... | ... |