index.js 843 B

12345678910111213141516171819202122232425262728293031323334
  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. info: null,
  14. title: String,
  15. disabled: Boolean,
  16. },
  17. methods: {
  18. onClick: function () {
  19. var _this = this;
  20. var parent = this.parent;
  21. if (!parent || this.data.disabled) {
  22. return;
  23. }
  24. var index = parent.children.indexOf(this);
  25. parent.setActive(index).then(function () {
  26. _this.$emit('click', index);
  27. parent.$emit('change', index);
  28. });
  29. },
  30. setActive: function (selected) {
  31. return this.setData({ selected: selected });
  32. },
  33. },
  34. });