index.js 889 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. component_1.VantComponent({
  5. relation: {
  6. type: 'ancestor',
  7. name: 'badge-group',
  8. linked: function (target) {
  9. this.parent = target;
  10. }
  11. },
  12. props: {
  13. info: null,
  14. title: String
  15. },
  16. methods: {
  17. onClick: function () {
  18. var _this = this;
  19. var parent = this.parent;
  20. if (!parent) {
  21. return;
  22. }
  23. var index = parent.badges.indexOf(this);
  24. parent.setActive(index).then(function () {
  25. _this.$emit('click', index);
  26. parent.$emit('change', index);
  27. });
  28. },
  29. setActive: function (active) {
  30. return this.set({ active: active });
  31. }
  32. }
  33. });