title.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div class="title" :class="{error: type === 'error', warning: type === 'warning'}">
  3. <div>
  4. <span v-for="(item, index) in data" :key="index">
  5. <span>{{item.name}}</span>
  6. <b>{{item.num}}</b>
  7. </span>
  8. </div>
  9. <slot/>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. type: {
  16. type: String,
  17. default: 'warning'
  18. },
  19. data: {
  20. type: Array,
  21. default: []
  22. }
  23. }
  24. }
  25. </script>
  26. <style lang="less" scoped>
  27. .title{
  28. height: 48px;
  29. line-height: 48px;
  30. background-color: rgba(0, 0, 0, .02);
  31. overflow: hidden;
  32. margin-bottom: 20px;
  33. display: flex;
  34. justify-content: space-between;
  35. padding-right: 10px;
  36. font-weight: bold;
  37. b{
  38. font-size: 18px;
  39. }
  40. &.error {
  41. b{
  42. color: #ED6F62;
  43. }
  44. &:before{
  45. background-color: #ED6F62;
  46. }
  47. }
  48. &.warning {
  49. b{
  50. color: #F2A24A;
  51. }
  52. &:before{
  53. background-color: #F2A24A;
  54. }
  55. }
  56. &:before{
  57. content: '';
  58. display: block;
  59. position: absolute;
  60. width: 7px;
  61. height: 48px;
  62. left: 0;
  63. }
  64. >div{
  65. position: relative;
  66. padding-left: 20px;
  67. font-size: 14px;
  68. >span{
  69. margin-right: 10px;
  70. display: inline-block;
  71. }
  72. }
  73. }
  74. </style>