搜索关键字变色

<template>
  <div>
    <p v-html="eachColor('有限ddf','有限')"></p>1
  </div>
</template>

<script>
export default {
  methods: {
    eachColor (content, searchVal) {
      const nt = '<span style="color:red">' + searchVal + '</span>'
      return content.replace(searchVal, nt) + ' '
    }
  }
}
</script>

<style>

</style>
https://blog.csdn.net/weixin_41542329/article/details/121750082

  

posted @ 2022-09-16 18:17  zjxgdq  阅读(21)  评论(0编辑  收藏  举报