uni-collapse.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="uni-collapse">
  3. <slot />
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'UniCollapse',
  9. props: {
  10. accordion: { // 是否开启手风琴效果
  11. type: Boolean,
  12. default: false
  13. }
  14. },
  15. data() {
  16. return {}
  17. },
  18. provide() {
  19. return {
  20. collapse: this
  21. }
  22. },
  23. created() {
  24. this.childrens = []
  25. },
  26. methods: {
  27. onChange() {
  28. let activeItem = []
  29. this.childrens.forEach((vm, index) => {
  30. if (vm.isOpen) {
  31. activeItem.push(vm.nameSync)
  32. }
  33. })
  34. this.$emit('change', activeItem)
  35. }
  36. }
  37. }
  38. </script>
  39. <style>
  40. @charset "UTF-8";
  41. .uni-collapse {
  42. background-color: #fff;
  43. position: relative;
  44. width: 100%;
  45. display: flex;
  46. flex-direction: column
  47. }
  48. .uni-collapse:after {
  49. position: absolute;
  50. z-index: 10;
  51. right: 0;
  52. bottom: 0;
  53. left: 0;
  54. height: 1px;
  55. content: '';
  56. -webkit-transform: scaleY(.5);
  57. transform: scaleY(.5);
  58. background-color: #c8c7cc
  59. }
  60. .uni-collapse:before {
  61. position: absolute;
  62. z-index: 10;
  63. right: 0;
  64. top: 0;
  65. left: 0;
  66. height: 1px;
  67. content: '';
  68. -webkit-transform: scaleY(.5);
  69. transform: scaleY(.5);
  70. background-color: #c8c7cc
  71. }
  72. </style>