props.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { defineProps } from '../../libs/util/props';
  2. export default defineProps('badge', {
  3. // 是否显示圆点
  4. isDot: {
  5. type: Boolean,
  6. default: false,
  7. },
  8. // 显示的内容
  9. value: {
  10. type: [Number, String],
  11. default: '',
  12. },
  13. // #ifdef VUE3
  14. modelValue: {
  15. type: [Number, String],
  16. default: '',
  17. },
  18. // #endif
  19. // 是否显示
  20. show: {
  21. type: Boolean,
  22. default: true,
  23. },
  24. // 最大值,超过最大值会显示 '{max}+'
  25. max: {
  26. type: [Number, String],
  27. default: 999,
  28. },
  29. // 主题类型,error|warning|success|primary
  30. type: {
  31. type: String,
  32. default: 'error',
  33. },
  34. // 当数值为 0 时,是否展示 Badge
  35. showZero: {
  36. type: Boolean,
  37. default: false,
  38. },
  39. // 背景颜色,优先级比type高,如设置,type参数会失效
  40. bgColor: {
  41. type: String,
  42. default: '',
  43. },
  44. // 字体颜色
  45. color: {
  46. type: String,
  47. default: '',
  48. },
  49. // 徽标形状,circle-四角均为圆角,horn-左下角为直角
  50. shape: {
  51. type: String,
  52. default: 'circle',
  53. },
  54. // 设置数字的显示方式,overflow|ellipsis|limit
  55. // overflow会根据max字段判断,超出显示`${max}+`
  56. // ellipsis会根据max判断,超出显示`${max}...`
  57. // limit会依据1000作为判断条件,超出1000,显示`${value/1000}K`,比如2.2k、3.34w,最多保留2位小数
  58. numberType: {
  59. type: String,
  60. default: 'overflow',
  61. },
  62. // 设置badge的位置偏移,格式为 [x, y],也即设置的为top和right的值,absolute为true时有效
  63. offset: {
  64. type: Array,
  65. default: () => [],
  66. },
  67. // 是否反转背景和字体颜色
  68. inverted: {
  69. type: Boolean,
  70. default: false,
  71. },
  72. // 是否绝对定位
  73. absolute: {
  74. type: Boolean,
  75. default: false,
  76. },
  77. });