Commit 78ff4d9452127129e2f4f7372942664e927c9e89
1 parent
6483d769
wip: bug修复
Showing
2 changed files
with
39 additions
and
19 deletions
src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue
src/views/basic/askTestQuestion/wrongQuestion.vue
... | ... | @@ -162,7 +162,9 @@ |
162 | 162 | </div> |
163 | 163 | <div> |
164 | 164 | <span class="color size"> 得分率: </span> |
165 | - <span class="score-color size">{{ item.scoreRate }}%</span> | |
165 | + <span class="score-color size" | |
166 | + >{{ formatNumber(item.scoreRate) }}%</span | |
167 | + > | |
166 | 168 | <span class="size font-weight" |
167 | 169 | >({{ item.joinClassNames }})</span |
168 | 170 | > |
... | ... | @@ -656,23 +658,23 @@ export default { |
656 | 658 | // let a = this.processString(firstP.innerHTML); |
657 | 659 | // firstP.innerHTML = a; |
658 | 660 | // } |
659 | - // const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
660 | - // const body = iframeRef.contentWindow.document.body; | |
661 | - // body.style.overflowX = "hidden"; // 不允许出现横向滚动条 | |
662 | - // const height = body.offsetHeight; // 获取内容的高度 | |
663 | - // console.log(height, "height"); | |
664 | - // // console.log("body.offsetHeight:", body.offsetHeight); | |
665 | - // // console.log("body.clientHeight:", body.clientHeight); | |
666 | - // // console.log("body.scrollHeight:", body.scrollHeight); | |
667 | - | |
668 | - // iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 | |
669 | - // // 获取第一个P标签 | |
670 | - // const firstP = doc.getElementsByTagName("p")[0]; | |
671 | - // // 或者修改第一个 < p > 标签的内容; | |
672 | - // if (firstP) { | |
673 | - // let a = this.processString(firstP.innerHTML); | |
674 | - // firstP.innerHTML = a; | |
675 | - // } | |
661 | + const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; | |
662 | + const body = iframeRef.contentWindow.document.body; | |
663 | + body.style.overflowX = "hidden"; // 不允许出现横向滚动条 | |
664 | + const height = body.offsetHeight; // 获取内容的高度 | |
665 | + console.log(height, "height"); | |
666 | + // console.log("body.offsetHeight:", body.offsetHeight); | |
667 | + // console.log("body.clientHeight:", body.clientHeight); | |
668 | + // console.log("body.scrollHeight:", body.scrollHeight); | |
669 | + | |
670 | + iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度 | |
671 | + // 获取第一个P标签 | |
672 | + const firstP = doc.getElementsByTagName("p")[0]; | |
673 | + // 或者修改第一个 < p > 标签的内容; | |
674 | + if (firstP) { | |
675 | + let a = this.processString(firstP.innerHTML); | |
676 | + firstP.innerHTML = a; | |
677 | + } | |
676 | 678 | }, |
677 | 679 | |
678 | 680 | // 子集删除后 父级需要更新 |
... | ... | @@ -686,6 +688,24 @@ export default { |
686 | 688 | this.analysisUrl = url; |
687 | 689 | this.analysisVisible = true; |
688 | 690 | }, |
691 | + | |
692 | + // 保留两位小数 | |
693 | + formatNumber(num) { | |
694 | + // 检查是否是数字 | |
695 | + if (typeof num !== "number") { | |
696 | + throw new Error("输入必须是数字"); | |
697 | + } | |
698 | + | |
699 | + // 检查小数位数 | |
700 | + const parts = num.toString().split("."); | |
701 | + if (parts.length === 2 && parts[1].length > 2) { | |
702 | + // 如果小数部分超过两位,保留两位小数 | |
703 | + return parseFloat(num.toFixed(2)); | |
704 | + } else { | |
705 | + // 否则返回原数据 | |
706 | + return num; | |
707 | + } | |
708 | + }, | |
689 | 709 | }, |
690 | 710 | }; |
691 | 711 | </script> | ... | ... |