cl-avatar-group.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="cl-avatar-group">
  3. <template v-for="(item, index) in urls">
  4. <cl-avatar
  5. v-if="index < max"
  6. :key="index"
  7. :size="size"
  8. :shape="shape"
  9. :mode="mode"
  10. :src="item"
  11. ></cl-avatar>
  12. </template>
  13. <cl-avatar :size="size" :shape="shape" v-if="overLen > 0 && showMore">
  14. <view class="cl-avatar-group__more"> {{ overLen }} </view>
  15. </cl-avatar>
  16. </view>
  17. </template>
  18. <script>
  19. /**
  20. * avatar-group 头像组
  21. * @description 头像组
  22. * @tutorial https://docs.cool-js.com/uni/components/view/avatar.html
  23. * @property {Array} urls 图片链接
  24. * @property {Number} max 最大数量,默认5
  25. * @property {Number} size 头像大小,默认80
  26. * @property {String} shape 头像的形状,默认circle
  27. * @property {String} mode 裁剪,缩放模式
  28. * @example <cl-avatar-group :urls="['http://']" />
  29. */
  30. export default {
  31. name: "cl-avatar-group",
  32. props: {
  33. urls: Array,
  34. size: {
  35. type: Number,
  36. default: 80,
  37. },
  38. max: {
  39. type: Number,
  40. default: 5,
  41. },
  42. shape: {
  43. type: String,
  44. default: "circle",
  45. },
  46. showMore: {
  47. type: Boolean,
  48. default: true,
  49. },
  50. mode: {
  51. type: String,
  52. default: "scaleToFill",
  53. },
  54. },
  55. computed: {
  56. overLen() {
  57. return this.urls.length - this.max;
  58. },
  59. },
  60. };
  61. </script>