index.js 860 B

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