瀏覽代碼

调整解析单词显示

wangxy 1 月之前
父節點
當前提交
1e1ece9897
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      pages/newEnglish/components/xiangjie.vue
  2. 2 2
      pages/newEnglish/components/xuePage.vue

+ 2 - 2
pages/newEnglish/components/xiangjie.vue

@@ -73,10 +73,10 @@
 			return text
 		}
 		const word = pageInfo.value.name;
-		const regex = new RegExp(word, 'gi');
+		const regex = /<([^>]+)>/g;
 		console.log('pageInfo.value.name', pageInfo.value.name);
 		return text.replace(regex, (match) => {
-			return `<span style="color: #3a7fe9;">${match}</span>`;
+			return `<span style="color: #3a7fe9;">${word}</span>`;
 		});
 	}
 	const handleBack = () => {

+ 2 - 2
pages/newEnglish/components/xuePage.vue

@@ -135,9 +135,9 @@
 			return text
 		}
 		const word = props.activeWord.name;
-		const regex = new RegExp(word, 'gi');
+		const regex = /<([^>]+)>/g;
 		return text.replace(regex, (match) => {
-			return `<span style="color: #3a7fe9;">${match}</span>`;
+			return `<span style="color: #3a7fe9;">${word}</span>`;
 		});
 	}