Pārlūkot izejas kodu

Merge branch 'sub-question-render' into baiyou

hehaitao 1 gadu atpakaļ
vecāks
revīzija
37c4c0d3ca
1 mainītis faili ar 12 papildinājumiem un 3 dzēšanām
  1. 12 3
      src/components/MxPaper/mx-question-mixin.js

+ 12 - 3
src/components/MxPaper/mx-question-mixin.js

@@ -76,9 +76,18 @@ export default {
       return !this.allowAnswer && !this.allowScore
     },
     questionWithSeq() {
-      let prefix = this.question.seq ? this.question.seq + '、' : ''
-      if (this.question.type) prefix += '[' + this.question.type + ']'
-      return prefix + this.question.title
+      const {seq, type, title} = this.question
+      let prefix = seq ? seq + '、' : ''
+      if (type) prefix += '[' + type + ']'
+      if (title?.startsWith('<div')||title?.startsWith('<p')) {
+        let tagBegin = /<(div|p)[^>]*>(\s|(&nbsp;))*/.exec(title)?.first()
+        if (tagBegin) {
+          const titleRest = title.substring(tagBegin.length)
+          tagBegin = tagBegin.replaceAll('&nbsp;', '').replaceAll(' ', '')
+          return tagBegin + prefix + titleRest
+        }
+      }
+      return prefix + title
     },
     optionsVisible() {
       return this.question.options && this.question.options.length