index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var component_1 = require('../common/component');
  4. var utils_1 = require('../common/utils');
  5. component_1.VantComponent({
  6. classes: ['title-class'],
  7. props: {
  8. title: String,
  9. fixed: {
  10. type: Boolean,
  11. observer: 'setHeight',
  12. },
  13. placeholder: {
  14. type: Boolean,
  15. observer: 'setHeight',
  16. },
  17. leftText: String,
  18. rightText: String,
  19. customStyle: String,
  20. leftArrow: Boolean,
  21. border: {
  22. type: Boolean,
  23. value: true,
  24. },
  25. zIndex: {
  26. type: Number,
  27. value: 1,
  28. },
  29. safeAreaInsetTop: {
  30. type: Boolean,
  31. value: true,
  32. },
  33. },
  34. data: {
  35. statusBarHeight: 0,
  36. height: 44,
  37. baseStyle: '',
  38. },
  39. created: function () {
  40. var statusBarHeight = utils_1.getSystemInfoSync().statusBarHeight;
  41. var _a = this.data,
  42. safeAreaInsetTop = _a.safeAreaInsetTop,
  43. zIndex = _a.zIndex;
  44. var paddingTop = safeAreaInsetTop ? statusBarHeight : 0;
  45. var baseStyle =
  46. 'z-index: ' + zIndex + ';padding-top: ' + paddingTop + 'px;';
  47. this.setData({
  48. statusBarHeight: statusBarHeight,
  49. height: 44 + statusBarHeight,
  50. baseStyle: baseStyle,
  51. });
  52. },
  53. mounted: function () {
  54. this.setHeight();
  55. },
  56. methods: {
  57. onClickLeft: function () {
  58. this.$emit('click-left');
  59. },
  60. onClickRight: function () {
  61. this.$emit('click-right');
  62. },
  63. setHeight: function () {
  64. var _this = this;
  65. if (!this.data.fixed || !this.data.placeholder) {
  66. return;
  67. }
  68. wx.nextTick(function () {
  69. _this.getRect('.van-nav-bar').then(function (res) {
  70. _this.setData({ height: res.height });
  71. });
  72. });
  73. },
  74. },
  75. });