index.js 1.7 KB

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