Badge.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <a-badge :count="text" :numberStyle="showStyle" />
  3. </template>
  4. <script>
  5. export default {
  6. name: 'Badge',
  7. props: {
  8. text: { // 按钮显示文本
  9. type: String,
  10. default: ''
  11. },
  12. status: { // 按钮显示文本
  13. type: String,
  14. default: 'success'
  15. },
  16. numberStyle: {
  17. type: Object,
  18. default: () => ({})
  19. }
  20. },
  21. data () {
  22. return {
  23. }
  24. },
  25. computed: {
  26. showStyle: function () {
  27. let myShowStyle = { ...{ backgroundColor: '#52c41a' } }
  28. if (this.status === 'success') {
  29. myShowStyle = { ...myShowStyle, ...{ backgroundColor: '#52c41a' } }
  30. }
  31. if (this.status === 'error') {
  32. myShowStyle = { ...myShowStyle, ...{ backgroundColor: '#f5222d' } }
  33. }
  34. if (this.status === 'default') {
  35. myShowStyle = { ...myShowStyle, ...{ backgroundColor: '#d9d9d9' } }
  36. }
  37. if (this.status === 'processing') {
  38. myShowStyle = { ...myShowStyle, ...{ backgroundColor: '#1890ff' } }
  39. }
  40. if (this.status === 'warning') {
  41. myShowStyle = { ...myShowStyle, ...{ backgroundColor: '#faad14' } }
  42. }
  43. if (this.status === 'gray') {
  44. myShowStyle = { ...myShowStyle, ...{ backgroundColor: '#7F7D77FF' } }
  45. }
  46. myShowStyle = { ...myShowStyle, ...this.numberStyle }
  47. return myShowStyle
  48. }
  49. },
  50. created () {
  51. },
  52. updated: function () {
  53. }
  54. }
  55. </script>
  56. <style scoped>
  57. </style>