index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view :class="'custom-class van-collapse ' + (border ? 'van-hairline--top-bottom' : '')">
  3. <slot />
  4. </view>
  5. </template>
  6. <script>
  7. 'use strict';
  8. Object.defineProperty(exports, '__esModule', {
  9. value: true
  10. });
  11. var component_1 = require('../common/component');
  12. component_1.VantComponent({
  13. relation: {
  14. name: 'collapse-item',
  15. type: 'descendant',
  16. current: 'collapse'
  17. },
  18. props: {
  19. value: {
  20. type: null,
  21. observer: 'updateExpanded'
  22. },
  23. accordion: {
  24. type: Boolean,
  25. observer: 'updateExpanded'
  26. },
  27. border: {
  28. type: Boolean,
  29. value: true
  30. }
  31. },
  32. methods: {
  33. updateExpanded: function () {
  34. this.children.forEach(function (child) {
  35. child.updateExpanded();
  36. });
  37. },
  38. switch: function (name, expanded) {
  39. var _a = this;
  40. var accordion = _a.accordion;
  41. var value = _a.value;
  42. var changeItem = name;
  43. if (!accordion) {
  44. name = expanded
  45. ? (value || []).concat(name)
  46. : (value || []).filter(function (activeName) {
  47. return activeName !== name;
  48. });
  49. } else {
  50. name = expanded ? name : '';
  51. }
  52. if (expanded) {
  53. this.$emit('open', changeItem);
  54. } else {
  55. this.$emit('close', changeItem);
  56. }
  57. this.$emit('change', name);
  58. this.$emit('input', name);
  59. }
  60. }
  61. });
  62. </script>
  63. <style>
  64. @import './index.css';
  65. </style>