index.js 747 B

12345678910111213141516171819202122232425262728293031
  1. import { VantComponent } from '../common/component';
  2. VantComponent({
  3. relation: {
  4. type: 'ancestor',
  5. name: 'sidebar',
  6. linked(target) {
  7. this.parent = target;
  8. }
  9. },
  10. props: {
  11. dot: Boolean,
  12. info: null,
  13. title: String
  14. },
  15. methods: {
  16. onClick() {
  17. const { parent } = this;
  18. if (!parent) {
  19. return;
  20. }
  21. const index = parent.items.indexOf(this);
  22. parent.setActive(index).then(() => {
  23. this.$emit('click', index);
  24. parent.$emit('change', index);
  25. });
  26. },
  27. setActive(active) {
  28. return this.setData({ active });
  29. }
  30. }
  31. });