index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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(
  54. children.map(function (child) {
  55. return child.updateFromParent();
  56. })
  57. );
  58. },
  59. onChange: function (child) {
  60. var index = this.children.indexOf(child);
  61. var active = child.data.name || index;
  62. if (active !== this.data.active) {
  63. this.$emit('change', active);
  64. }
  65. },
  66. },
  67. });