vue3 搜索关键字变颜色
let inputNews = ref('') let element = ref('') const seachNews = (contentText) => { for (let j = 0; j < contentText.length; j++) { element = contentText[j]; // 刷新列表数据 let res = element.title if (inputNews.value == '') { return res; } else { let wordsArray = res.split(''); for (var i = 0; i < wordsArray.length; i++) { if (inputNews.value.includes(wordsArray[i])) { wordsArray[i] = "<span style='color: red;'>" + wordsArray[i] + '</span>'; } } res = wordsArray.join(''); console.log(res) contentText[j].title = res console.log(contentText) } } }