|
@@ -56,10 +56,7 @@
|
|
|
<text class="details-title">实用口语</text>
|
|
|
<view v-for="(item,index) in activeWord.kouyu" :key="index" class="syky-content">
|
|
|
<view class="details-en-content">
|
|
|
- <view>{{item.en}}</view>
|
|
|
- <!-- 变色 word-color-->
|
|
|
- <!-- <text class="word-color">{{item.en}}</text>
|
|
|
- <text>{{item.en}}</text> -->
|
|
|
+ <rich-text :nodes="highlightWord(item.en)"></rich-text>
|
|
|
</view>
|
|
|
<view class="details-cn-content">{{item.zn}}</view>
|
|
|
</view>
|
|
@@ -115,6 +112,15 @@
|
|
|
},
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+ const highlightWord = (text) => {
|
|
|
+ if (!text || !props.activeWord.name){return text}
|
|
|
+ const word = props.activeWord.name;
|
|
|
+ const regex = new RegExp(word, 'gi');
|
|
|
+ return text.replace(regex, (match) => {
|
|
|
+ return `<span style="color: #3a7fe9;">${match}</span>`;
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
async function handlePlay(opt) {
|
|
|
emits('play-audio', opt)
|