index.js 1.6 KB

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