props.js 2.4 KB

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