index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. height: 46,
  36. },
  37. created: function () {
  38. var statusBarHeight = utils_1.getSystemInfoSync().statusBarHeight;
  39. this.setData({
  40. statusBarHeight: statusBarHeight,
  41. height: 46 + statusBarHeight,
  42. });
  43. },
  44. mounted: function () {
  45. this.setHeight();
  46. },
  47. methods: {
  48. onClickLeft: function () {
  49. this.$emit('click-left');
  50. },
  51. onClickRight: function () {
  52. this.$emit('click-right');
  53. },
  54. setHeight: function () {
  55. var _this = this;
  56. if (!this.data.fixed || !this.data.placeholder) {
  57. return;
  58. }
  59. wx.nextTick(function () {
  60. utils_1.getRect(_this, '.van-nav-bar').then(function (res) {
  61. if (res && 'height' in res) {
  62. _this.setData({ height: res.height });
  63. }
  64. });
  65. });
  66. },
  67. },
  68. });