index.js 831 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. var _component = require("../common/component");
  3. (0, _component.VantComponent)({
  4. classes: ["active-class", "disabled-class"],
  5. relation: {
  6. type: "ancestor",
  7. name: "sidebar",
  8. current: "sidebar-item"
  9. },
  10. props: {
  11. dot: Boolean,
  12. badge: null,
  13. info: null,
  14. title: String,
  15. disabled: Boolean
  16. },
  17. methods: {
  18. onClick: function onClick() {
  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 setActive(selected) {
  31. return this.setData({
  32. selected: selected
  33. });
  34. }
  35. }
  36. });