Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

85 linhas
2.6 KiB

  1. import { defineMixin } from '../../libs/vue'
  2. import AvatarDefaultProps from './avatar'
  3. import { registerComponentProps } from '../../libs/config/props.js'
  4. const defProps = registerComponentProps(AvatarDefaultProps)
  5. import test from '../../libs/function/test';
  6. export const props = defineMixin({
  7. props: {
  8. // 头像图片路径(不能为相对路径)
  9. src: {
  10. type: String,
  11. default: () => defProps.avatar.src
  12. },
  13. // 头像形状,circle-圆形,square-方形
  14. shape: {
  15. type: String,
  16. default: () => defProps.avatar.shape
  17. },
  18. // 头像尺寸
  19. size: {
  20. type: [String, Number],
  21. default: () => defProps.avatar.size
  22. },
  23. // 裁剪模式
  24. mode: {
  25. type: String,
  26. default: () => defProps.avatar.mode
  27. },
  28. // 显示的文字
  29. text: {
  30. type: String,
  31. default: () => defProps.avatar.text
  32. },
  33. // 背景色
  34. bgColor: {
  35. type: String,
  36. default: () => defProps.avatar.bgColor
  37. },
  38. // 文字颜色
  39. color: {
  40. type: String,
  41. default: () => defProps.avatar.color
  42. },
  43. // 文字大小
  44. fontSize: {
  45. type: [String, Number],
  46. default: () => defProps.avatar.fontSize
  47. },
  48. // 显示的图标
  49. icon: {
  50. type: String,
  51. default: () => defProps.avatar.icon
  52. },
  53. // 显示小程序头像,只对百度,微信,QQ小程序有效
  54. mpAvatar: {
  55. type: Boolean,
  56. default: () => defProps.avatar.mpAvatar
  57. },
  58. // 是否使用随机背景色
  59. randomBgColor: {
  60. type: Boolean,
  61. default: () => defProps.avatar.randomBgColor
  62. },
  63. // 加载失败的默认头像(组件有内置默认图片)
  64. defaultUrl: {
  65. type: String,
  66. default: () => defProps.avatar.defaultUrl
  67. },
  68. // 如果配置了randomBgColor为true,且配置了此值,则从默认的背景色数组中取出对应索引的颜色值,取值0-19之间
  69. colorIndex: {
  70. type: [String, Number],
  71. // 校验参数规则,索引在0-19之间
  72. validator(n) {
  73. return test.range(n, [0, 19]) || n === ''
  74. },
  75. default: () => defProps.avatar.colorIndex
  76. },
  77. // 组件标识符
  78. name: {
  79. type: String,
  80. default: () => defProps.avatar.name
  81. }
  82. }
  83. })