XrMenuItem.vue 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div
  3. :class="{'is-select':select}"
  4. class="xr-menu-item">
  5. <i
  6. :style="{backgroundColor: select ? iconColor || '#2362FB' : '#edf2f6'}"
  7. :class="['xr-menu-item__icon', iconClass]" />
  8. <span class="xr-menu-item__label">{{ label }}</span>
  9. <el-badge
  10. v-if="num > 0"
  11. :max="99"
  12. :value="num"/>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. // 菜单
  18. name: 'XrMenuItem',
  19. components: {},
  20. props: {
  21. iconClass: String,
  22. iconColor: String,
  23. label: String,
  24. // 关键字
  25. name: String,
  26. num: [String, Number],
  27. select: Boolean
  28. },
  29. data() {
  30. return {}
  31. },
  32. computed: {},
  33. watch: {},
  34. mounted() {},
  35. beforeDestroy() {},
  36. methods: {}
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. .xr-menu-item {
  41. padding: 12px 20px;
  42. position: relative;
  43. cursor: pointer;
  44. &__icon {
  45. display: inline-block;
  46. font-size: 12px;
  47. padding: 6px;
  48. border-radius: $xr-border-radius-base;
  49. background-color: #edf2f6;
  50. color: #8a94a6;;
  51. }
  52. &__label {
  53. color: #333;
  54. font-size: 13px;
  55. margin-left: 10px;
  56. }
  57. &.is-select {
  58. .xr-menu-item__icon {
  59. background-color: $xr-color-primary;
  60. color: white;
  61. }
  62. }
  63. }
  64. .xr-menu-item.is-select,
  65. .xr-menu-item:hover {
  66. background-color: $xr--background-color-base;
  67. }
  68. .xr-menu-item::before {
  69. content: ' ';
  70. position: absolute;
  71. left: 0;
  72. top: 0;
  73. bottom: 0;
  74. width: 2px;
  75. background-color: $xr-color-primary;
  76. opacity: 0;
  77. }
  78. .xr-menu-item.is-select::before {
  79. opacity: 1;
  80. }
  81. .el-badge /deep/ .el-badge__content {
  82. border: none;
  83. top: 0;
  84. }
  85. .el-badge {
  86. position: absolute;
  87. right: 10px;
  88. top: 15px;
  89. }
  90. </style>