储能智慧云小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

using-custom-navbar.js 957B

123456789101112131415161718192021222324252627282930313233
  1. const useCustomNavbarBehavior = Behavior({
  2. properties: {
  3. usingCustomNavbar: {
  4. type: Boolean,
  5. value: false,
  6. },
  7. customNavbarHeight: {
  8. type: Number,
  9. value: 0,
  10. },
  11. },
  12. data: {
  13. distanceTop: 0,
  14. },
  15. lifetimes: {
  16. attached() {
  17. if (this.properties.usingCustomNavbar) {
  18. this.calculateCustomNavbarDistanceTop();
  19. }
  20. },
  21. },
  22. methods: {
  23. calculateCustomNavbarDistanceTop() {
  24. const { statusBarHeight } = wx.getSystemInfoSync();
  25. const menuButton = wx.getMenuButtonBoundingClientRect();
  26. const distance = menuButton.top + menuButton.bottom - statusBarHeight;
  27. this.setData({
  28. distanceTop: Math.max(distance, this.properties.customNavbarHeight + statusBarHeight),
  29. });
  30. },
  31. },
  32. });
  33. export default useCustomNavbarBehavior;