vue搜索关键字字体高亮, map映射新数组,replace替换,font字体样式

.then(res => {
          res.detail.list.map((item,i)=>{
            item.smsMsg=this.brightenKeyword(item.smsMsg,this.pagination.content)
          })  //调用brightenKeyword方法
          this.tableData3 = res.detail.list;
          this.count = res.detail.count;

//高亮搜索字体 
    brightenKeyword(val, keyword) {
      val = val + '';  
      if (val.indexOf(keyword) !== -1 && keyword !== '') {       
        return val.replace(keyword, '<font color="#409EFF">' + keyword + '</font>')
      } else {      
        return val
      }
    },

  

原文地址:https://www.cnblogs.com/guanhuohuo/p/12533670.html