index.vue 1.8 KB

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