main.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div
  3. class="basic-container"
  4. :style="styleName"
  5. :class="{ 'basic-container--block': block }"
  6. >
  7. <el-card class="basic-container__card">
  8. <div v-show="show">
  9. <slot></slot>
  10. </div>
  11. <div v-if="showBtn" class="basic-container-foot" @click="show = !show" @mouseenter="enter" @mouseleave="leave">
  12. <div v-show="show">
  13. <i class="el-icon-caret-top" /><span v-show="showSpan">隐藏</span>
  14. </div>
  15. <div v-show="!show">
  16. <i class="el-icon-caret-bottom" /><span v-show="showSpan">显示</span>
  17. </div>
  18. </div>
  19. </el-card>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: "basicContainer",
  25. data() {
  26. return {
  27. show: true,
  28. showSpan: false
  29. };
  30. },
  31. props: {
  32. radius: {
  33. type: [String, Number],
  34. default: 10
  35. },
  36. background: {
  37. type: String
  38. },
  39. block: {
  40. type: Boolean,
  41. default: false
  42. },
  43. showBtn: {
  44. type: Boolean,
  45. default: false
  46. }
  47. },
  48. methods: {
  49. enter() {
  50. this.showSpan = true;
  51. },
  52. leave() {
  53. this.showSpan = false;
  54. }
  55. },
  56. computed: {
  57. styleName() {
  58. return {
  59. borderRadius: this.setPx(this.radius),
  60. background: this.background
  61. };
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. .basic-container {
  68. padding: 5px 6px;
  69. box-sizing: border-box;
  70. &--block {
  71. height: 100%;
  72. .basic-container__card {
  73. height: 100%;
  74. }
  75. }
  76. &__card {
  77. width: 100%;
  78. }
  79. &:first-child {
  80. padding-top: 6px;
  81. }
  82. &-foot {
  83. cursor: pointer;
  84. display: flex;
  85. justify-content: center;
  86. align-items: center;
  87. color: #d3dce6;
  88. span {
  89. margin-left: 4px;
  90. font-size: 14px;
  91. }
  92. }
  93. &-foot:hover {
  94. color: #409eff;
  95. }
  96. }
  97. </style>