index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. component_1.VantComponent({
  5. relation: {
  6. name: 'tabbar-item',
  7. type: 'descendant',
  8. current: 'tabbar',
  9. linked: function (target) {
  10. target.parent = this;
  11. target.updateFromParent();
  12. },
  13. unlinked: function () {
  14. this.updateChildren();
  15. }
  16. },
  17. props: {
  18. active: {
  19. type: null,
  20. observer: 'updateChildren'
  21. },
  22. activeColor: {
  23. type: String,
  24. observer: 'updateChildren'
  25. },
  26. inactiveColor: {
  27. type: String,
  28. observer: 'updateChildren'
  29. },
  30. fixed: {
  31. type: Boolean,
  32. value: true
  33. },
  34. border: {
  35. type: Boolean,
  36. value: true
  37. },
  38. zIndex: {
  39. type: Number,
  40. value: 1
  41. },
  42. safeAreaInsetBottom: {
  43. type: Boolean,
  44. value: true
  45. }
  46. },
  47. methods: {
  48. updateChildren: function () {
  49. var children = this.children;
  50. if (!Array.isArray(children) || !children.length) {
  51. return Promise.resolve();
  52. }
  53. return Promise.all(children.map(function (child) { return child.updateFromParent(); }));
  54. },
  55. onChange: function (child) {
  56. var index = this.children.indexOf(child);
  57. var active = child.data.name || index;
  58. if (active !== this.data.active) {
  59. this.$emit('change', active);
  60. }
  61. }
  62. }
  63. });