highlight: function(keyWords, resultsList) {
      if (keyWords && keyWords.length > 0) {
        // 匹配关键字正则
        let replaceReg = new RegExp(keyWords, 'g')
        // 高亮替换v-html值
        let replaceString =
          '<span style="color:red">' + keyWords + '</span>'
        resultsList = resultsList.replace(
          replaceReg,
          replaceString
        )
      }
      return resultsList
    },

  

posted on 2019-11-21 11:19  前端入门菜鸟  阅读(378)  评论(0编辑  收藏  举报