AIcon.vue 875 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <template>
  2. <Icon :icon="icon" :size="size"></Icon>
  3. </template>
  4. <script lang="ts">
  5. import { computed, defineComponent } from 'vue';
  6. import { Icon } from '/@/components/Icon';
  7. import { isEmpty } from '/@/utils/is';
  8. import { propTypes } from '/@/utils/propTypes';
  9. export default defineComponent({
  10. name: 'AIcon',
  11. components: { Icon },
  12. props: {
  13. icon: String,
  14. type: String,
  15. // 图标大小,默认 16
  16. size: propTypes.any,
  17. // 样式
  18. theme: propTypes.any,
  19. },
  20. setup(props) {
  21. const icon = computed(() => {
  22. if (props.icon && !isEmpty(props.icon)) {
  23. return props.icon;
  24. }
  25. let iconTheme = props.theme ? `-${props.theme}` : '';
  26. return `ant-design:${props.type}${iconTheme}`;
  27. });
  28. return {
  29. icon,
  30. };
  31. },
  32. });
  33. </script>
  34. <style scoped></style>