index.vue 527 B

123456789101112131415161718192021222324252627282930
  1. <template>
  2. <span class="material-symbols-rounded" :class="classVal">{{nameVal}}</span>
  3. </template>
  4. <script setup>
  5. import { ref,watch } from "vue"
  6. const props = defineProps({
  7. ui: {
  8. type: String,
  9. default: ''
  10. },
  11. name: {
  12. type: [String,Number],
  13. default: ''
  14. }
  15. })
  16. //初始变量
  17. const classVal = ref(props.ui)
  18. const nameVal = ref(props.name)
  19. //监听
  20. watch(() => [
  21. props.ui,
  22. props.name,
  23. ], ([ui,name]) => {
  24. classVal.value = ui;
  25. nameVal.value = name;
  26. })
  27. </script>