HighLight.vue 551 B

12345678910111213141516171819202122232425262728293031
  1. <template>
  2. <a-tag class="oc-tag mb-2" v-html="wrapperKeyword(k, v)" />
  3. </template>
  4. <script>
  5. export default {
  6. name: 'HighLight',
  7. props: {
  8. k: {
  9. type: String,
  10. },
  11. v: {
  12. type: String,
  13. },
  14. },
  15. methods: {
  16. wrapperKeyword: (k, v) => {
  17. function highlight (value) {
  18. return `<span class='font-weight-bold error-color'>${value}</span>`
  19. }
  20. return v.replace(new RegExp(k, 'ig'), v => highlight(v))
  21. },
  22. },
  23. }
  24. </script>
  25. <style lang="scss" scoped>
  26. .oc-tag {
  27. cursor: pointer !important;
  28. }
  29. </style>