index.js 862 B

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