index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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) {
  55. return child.updateFromParent();
  56. });
  57. },
  58. setHeight: function () {
  59. var _this = this;
  60. if (!this.data.fixed || !this.data.placeholder) {
  61. return;
  62. }
  63. wx.nextTick(function () {
  64. utils_1.getRect(_this, '.van-tabbar').then(function (res) {
  65. _this.setData({ height: res.height });
  66. });
  67. });
  68. },
  69. },
  70. });