优化关键词显示

This commit is contained in:
刘祥超
2021-07-08 16:23:51 +08:00
parent ed59994db8
commit be8988d309

View File

@@ -4,12 +4,18 @@ Vue.component("keyword", {
let word = this.vWord
if (word == null) {
word = ""
} else {
word = word.replace(/\)/, "\\)")
word = word.replace(/\(/, "\\(")
word = word.replace(/\+/, "\\+")
word = word.replace(/\^/, "\\^")
word = word.replace(/\$/, "\\$")
}
let slot = this.$slots["default"][0]
let text = slot.text
if (word.length > 0) {
text = text.replace(new RegExp(word, "g"), "<span style=\"border: 1px #ccc dashed; color: #ef4d58\">" + word + "</span>")
text = text.replace(new RegExp("(" + word + ")", "ig"), "<span style=\"border: 1px #ccc dashed; color: #ef4d58\">$1</span>")
}
return {