pageTitle.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div>
  3. <!-- <div :style="{
  4. 'margin-top': safeAreaTop,
  5. 'height': '60rpx',
  6. }">
  7. </div> -->
  8. <div
  9. class="text-white bold text-center mt-2 pageTitle"
  10. :style="{
  11. 'margin-top': safeAreaTop,
  12. color: color,
  13. }"
  14. >
  15. <uni-icons
  16. type="left"
  17. size="20"
  18. :color="color"
  19. :style="{
  20. position: 'absolute',
  21. left: 0,
  22. 'margin-left': '20rpx',
  23. }"
  24. @click="back"
  25. ></uni-icons>
  26. {{ title }}
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. props: {
  33. title: {
  34. type: String,
  35. default: '',
  36. },
  37. color: {
  38. type: String,
  39. default: '#000',
  40. },
  41. },
  42. data() {
  43. return {
  44. safeAreaTop: '88rpx',
  45. }
  46. },
  47. mounted() {
  48. this.getSafeAreaTop()
  49. },
  50. methods: {
  51. getSafeAreaTop() {
  52. wx.getSystemInfo({
  53. success: res => {
  54. this.safeAreaTop = res.safeArea.top + 'px'
  55. },
  56. })
  57. },
  58. back() {
  59. wx.navigateBack({ delta: 1 })
  60. },
  61. },
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .pageTitle {
  66. z-index: 10;
  67. position: relative;
  68. height: 80rpx;
  69. width: 100vw;
  70. display: flex;
  71. align-items: center;
  72. justify-content: center;
  73. }
  74. </style>