index.tsx 842 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { defineComponent, type PropType } from "vue";
  2. import { UserFilled } from "@element-plus/icons-vue";
  3. export default defineComponent({
  4. name: "cl-avatar",
  5. props: {
  6. modelValue: String,
  7. src: String,
  8. icon: {
  9. type: null,
  10. default: UserFilled
  11. },
  12. size: [String, Number] as PropType<"large" | "default" | "small" | number>,
  13. shape: {
  14. type: String as PropType<"circle" | "square">,
  15. default: "square"
  16. },
  17. fit: {
  18. type: String as PropType<"fill" | "contain" | "cover" | "none" | "scale-down">,
  19. default: "cover"
  20. }
  21. },
  22. setup(props) {
  23. return () => {
  24. return (
  25. <el-avatar
  26. style={{
  27. display: "block",
  28. margin: "auto",
  29. height: props.size + "px",
  30. width: props.size + "px"
  31. }}
  32. {...{
  33. ...props,
  34. src: props.modelValue || props.src
  35. }}
  36. />
  37. );
  38. };
  39. }
  40. });