uni-collapse.vue 837 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // 是否开启手风琴效果
  12. type: [Boolean, String],
  13. default: false
  14. }
  15. },
  16. data() {
  17. return {};
  18. },
  19. provide() {
  20. return {
  21. collapse: this
  22. };
  23. },
  24. created() {
  25. this.childrens = [];
  26. },
  27. methods: {
  28. onChange() {
  29. let activeItem = [];
  30. this.childrens.forEach((vm, index) => {
  31. if (vm.isOpen) {
  32. activeItem.push(vm.nameSync);
  33. }
  34. });
  35. this.$emit('change', activeItem);
  36. }
  37. }
  38. };
  39. </script>
  40. <style lang="scss" scoped>
  41. .uni-collapse {
  42. /* #ifndef APP-NVUE */
  43. display: flex;
  44. /* #endif */
  45. /* #ifdef APP-NVUE */
  46. flex: 1;
  47. /* #endif */
  48. width: calc(100vw - 60upx);
  49. margin: 0 30upx 20upx;
  50. flex-direction: column;
  51. background-color: $color-white;
  52. }
  53. </style>