props.js 2.4 KB

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