index.js 1012 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { createNamespace } from '../utils';
  2. import { ParentMixin } from '../mixins/relation';
  3. import { BORDER_TOP_BOTTOM } from '../utils/constant';
  4. var _createNamespace = createNamespace('collapse'),
  5. createComponent = _createNamespace[0],
  6. bem = _createNamespace[1];
  7. export default createComponent({
  8. mixins: [ParentMixin('vanCollapse')],
  9. props: {
  10. accordion: Boolean,
  11. value: [String, Number, Array],
  12. border: {
  13. type: Boolean,
  14. default: true
  15. }
  16. },
  17. methods: {
  18. switch: function _switch(name, expanded) {
  19. if (!this.accordion) {
  20. name = expanded ? this.value.concat(name) : this.value.filter(function (activeName) {
  21. return activeName !== name;
  22. });
  23. }
  24. this.$emit('change', name);
  25. this.$emit('input', name);
  26. }
  27. },
  28. render: function render() {
  29. var _ref;
  30. var h = arguments[0];
  31. return h("div", {
  32. "class": [bem(), (_ref = {}, _ref[BORDER_TOP_BOTTOM] = this.border, _ref)]
  33. }, [this.slots()]);
  34. }
  35. });