index.vue 668 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div class="fold-box">
  3. <div class="tip" @click="fold = !fold">{{title || '点击以展开或折叠'}}</div>
  4. <div :class="`fold-container ${fold && 'fold'}`">
  5. <slot></slot>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'FoldBox',
  12. props: ['title'],
  13. data () {
  14. return {
  15. fold: true
  16. }
  17. }
  18. }
  19. </script>
  20. <style lang="less">
  21. .fold-box {
  22. margin: 10px 0px;
  23. .tip {
  24. height: 40px;
  25. line-height: 40px;
  26. text-align: center;
  27. color: #3eaf7c;
  28. cursor: pointer;
  29. }
  30. .fold-container {
  31. transition: all 0.5s;
  32. height: auto;
  33. }
  34. .fold {
  35. height: 0px;
  36. overflow: hidden;
  37. }
  38. }
  39. </style>