index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="CustomNavbar" :style="{backgroundColor: bgColor}">
  3. <view class="empty" :style="{height: statusBarHeight + 2 +'px'}"></view>
  4. <view
  5. class="Navbar"
  6. :style="{height: ( bounding.top - statusBarHeight ) * 2 + bounding.height + 'px'}"
  7. >
  8. <van-icon name="arrow-left" size="40rpx" class="arrow-left" @click="jumpPage"/>
  9. <view class="title">{{title}}</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'CustomNavbar',
  16. props: {
  17. title: {
  18. type: String,
  19. default: ''
  20. },
  21. bgColor: {
  22. type: String,
  23. default: '#fff'
  24. }
  25. },
  26. computed: {
  27. statusBarHeight () {
  28. return this.$store.state.systemInfo.statusBarHeight
  29. },
  30. bounding () {
  31. return this.$store.state.bounding
  32. }
  33. },
  34. methods: {
  35. jumpPage () {
  36. uni.navigateBack({
  37. delta: 1
  38. })
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped lang="less">
  44. .CustomNavbar {
  45. background-color: #fff;
  46. width: 100%;
  47. z-index: 10;
  48. .empty {
  49. width: 100%;
  50. }
  51. .Navbar {
  52. display: flex;
  53. align-items: center;
  54. position: relative;
  55. .arrow-left {
  56. position: absolute;
  57. left: 40rpx;
  58. }
  59. .title {
  60. width: 300rpx;
  61. height: 300rpx;
  62. font-size: 36rpx;
  63. font-weight:500;
  64. position: absolute;
  65. left: 50%;
  66. transform: translateX(-50%);
  67. }
  68. }
  69. }
  70. </style>