浏览代码

question content wrap style update

hehaitao 1 年之前
父节点
当前提交
b4500d59a7
共有 1 个文件被更改,包括 12 次插入3 次删除
  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