uni-collapse.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. this.$emit('change2', vm)
  33. }
  34. })
  35. this.$emit('change', activeItem)
  36. }
  37. }
  38. }
  39. </script>
  40. <style>
  41. @charset "UTF-8";
  42. .uni-collapse {
  43. background-color: #fff;
  44. position: relative;
  45. width: 100%;
  46. display: flex;
  47. flex-direction: column
  48. }
  49. .uni-collapse:after {
  50. position: absolute;
  51. z-index: 10;
  52. right: 0;
  53. bottom: 0;
  54. left: 0;
  55. height: 1px;
  56. content: '';
  57. -webkit-transform: scaleY(.5);
  58. transform: scaleY(.5);
  59. background-color: #c8c7cc
  60. }
  61. .uni-collapse:before {
  62. position: absolute;
  63. z-index: 10;
  64. right: 0;
  65. top: 0;
  66. left: 0;
  67. height: 1px;
  68. content: '';
  69. -webkit-transform: scaleY(.5);
  70. transform: scaleY(.5);
  71. background-color: #c8c7cc
  72. }
  73. </style>