index.js 817 B

1234567891011121314151617181920212223242526272829
  1. import { VantComponent } from '../common/component';
  2. import { useParent } from '../common/relation';
  3. VantComponent({
  4. classes: ['active-class', 'disabled-class'],
  5. relation: useParent('sidebar'),
  6. props: {
  7. dot: Boolean,
  8. badge: null,
  9. info: null,
  10. title: String,
  11. disabled: Boolean,
  12. },
  13. methods: {
  14. onClick() {
  15. const { parent } = this;
  16. if (!parent || this.data.disabled) {
  17. return;
  18. }
  19. const index = parent.children.indexOf(this);
  20. parent.setActive(index).then(() => {
  21. this.$emit('click', index);
  22. parent.$emit('change', index);
  23. });
  24. },
  25. setActive(selected) {
  26. return this.setData({ selected });
  27. },
  28. },
  29. });