u-tabbar.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "u-tabbar",
  5. mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$3],
  6. data() {
  7. return {
  8. placeholderHeight: 0
  9. };
  10. },
  11. computed: {
  12. tabbarStyle() {
  13. const style = {
  14. zIndex: this.zIndex
  15. };
  16. return common_vendor.index.$u.deepMerge(style, common_vendor.index.$u.addStyle(this.customStyle));
  17. },
  18. // 监听多个参数的变化,通过在computed执行对应的操作
  19. updateChild() {
  20. return [this.value, this.activeColor, this.inactiveColor];
  21. },
  22. updatePlaceholder() {
  23. return [this.fixed, this.placeholder];
  24. }
  25. },
  26. watch: {
  27. updateChild() {
  28. this.updateChildren();
  29. },
  30. updatePlaceholder() {
  31. this.setPlaceholderHeight();
  32. }
  33. },
  34. created() {
  35. this.children = [];
  36. },
  37. mounted() {
  38. this.setPlaceholderHeight();
  39. },
  40. methods: {
  41. updateChildren() {
  42. this.children.length && this.children.map((child) => child.updateFromParent());
  43. },
  44. // 设置用于防止塌陷元素的高度
  45. async setPlaceholderHeight() {
  46. if (!this.fixed || !this.placeholder)
  47. return;
  48. await common_vendor.index.$u.sleep(20);
  49. this.$uGetRect(".u-tabbar__content").then(({ height = 50 }) => {
  50. this.placeholderHeight = height;
  51. });
  52. }
  53. }
  54. };
  55. if (!Array) {
  56. const _easycom_u_safe_bottom2 = common_vendor.resolveComponent("u-safe-bottom");
  57. _easycom_u_safe_bottom2();
  58. }
  59. const _easycom_u_safe_bottom = () => "../u-safe-bottom/u-safe-bottom.js";
  60. if (!Math) {
  61. _easycom_u_safe_bottom();
  62. }
  63. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  64. return common_vendor.e({
  65. a: _ctx.safeAreaInsetBottom
  66. }, _ctx.safeAreaInsetBottom ? {} : {}, {
  67. b: common_vendor.o((...args) => _ctx.noop && _ctx.noop(...args)),
  68. c: common_vendor.n(_ctx.border && "u-border-top"),
  69. d: common_vendor.n(_ctx.fixed && "u-tabbar--fixed"),
  70. e: common_vendor.s($options.tabbarStyle),
  71. f: _ctx.placeholder
  72. }, _ctx.placeholder ? {
  73. g: $data.placeholderHeight + "px"
  74. } : {});
  75. }
  76. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-d5be2d5d"], ["__file", "F:/兴元/开门柜项目/平台端管理系统小程序/node_modules/uview-plus/components/u-tabbar/u-tabbar.vue"]]);
  77. wx.createComponent(Component);