index.vue 782 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <i class="hc-icon-i" :class="[`ri-${nameVal}${isFill ? '-fill' : line ? '-line' : ''}`, hui]"></i>
  3. </template>
  4. <script setup>
  5. import { ref,watch } from "vue"
  6. const props = defineProps({
  7. ui: {
  8. type: String,
  9. default: ''
  10. },
  11. //图标名
  12. name: {
  13. type: [String,Number],
  14. default: ''
  15. },
  16. //是否填充
  17. fill: {
  18. type: Boolean,
  19. default: false
  20. },
  21. line: {
  22. type: Boolean,
  23. default: true
  24. },
  25. })
  26. //初始变量
  27. const hui = ref(props.ui)
  28. const nameVal = ref(props.name)
  29. const isFill = ref(props.fill)
  30. //监听
  31. watch(() => [
  32. props.ui,
  33. props.name,
  34. props.fill,
  35. ], ([ui,name,fill]) => {
  36. hui.value = ui;
  37. nameVal.value = name;
  38. isFill.value = fill;
  39. })
  40. </script>