index.js 993 B

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. component_1.VantComponent({
  5. classes: [
  6. 'active-class',
  7. 'disabled-class',
  8. ],
  9. relation: {
  10. type: 'ancestor',
  11. name: 'sidebar',
  12. current: 'sidebar-item',
  13. },
  14. props: {
  15. dot: Boolean,
  16. info: null,
  17. title: String,
  18. disabled: Boolean
  19. },
  20. methods: {
  21. onClick: function () {
  22. var _this = this;
  23. var parent = this.parent;
  24. if (!parent || this.data.disabled) {
  25. return;
  26. }
  27. var index = parent.children.indexOf(this);
  28. parent.setActive(index).then(function () {
  29. _this.$emit('click', index);
  30. parent.$emit('change', index);
  31. });
  32. },
  33. setActive: function (selected) {
  34. return this.setData({ selected: selected });
  35. }
  36. }
  37. });