index.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. var relation_1 = require("../common/relation");
  5. var utils_1 = require("../common/utils");
  6. component_1.VantComponent({
  7. relation: relation_1.useChildren('tabbar-item', function () {
  8. this.updateChildren();
  9. }),
  10. props: {
  11. active: {
  12. type: null,
  13. observer: 'updateChildren',
  14. },
  15. activeColor: {
  16. type: String,
  17. observer: 'updateChildren',
  18. },
  19. inactiveColor: {
  20. type: String,
  21. observer: 'updateChildren',
  22. },
  23. fixed: {
  24. type: Boolean,
  25. value: true,
  26. observer: 'setHeight',
  27. },
  28. placeholder: {
  29. type: Boolean,
  30. observer: 'setHeight',
  31. },
  32. border: {
  33. type: Boolean,
  34. value: true,
  35. },
  36. zIndex: {
  37. type: Number,
  38. value: 1,
  39. },
  40. safeAreaInsetBottom: {
  41. type: Boolean,
  42. value: true,
  43. },
  44. },
  45. data: {
  46. height: 50,
  47. },
  48. methods: {
  49. updateChildren: function () {
  50. var children = this.children;
  51. if (!Array.isArray(children) || !children.length) {
  52. return;
  53. }
  54. children.forEach(function (child) { return child.updateFromParent(); });
  55. },
  56. setHeight: function () {
  57. var _this = this;
  58. if (!this.data.fixed || !this.data.placeholder) {
  59. return;
  60. }
  61. wx.nextTick(function () {
  62. utils_1.getRect(_this, '.van-tabbar').then(function (res) {
  63. _this.setData({ height: res.height });
  64. });
  65. });
  66. },
  67. },
  68. });