TitleHeader.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-WEIXIN -->
  4. <view class="navigation" :style="'height:'+navHeight+'px;line-height:'+navHeight+'px;'+(backgroundColor?('color:#fff;background-color:'+backgroundColor):'')">{{config.site_name}}</view>
  5. <!-- #endif -->
  6. </view>
  7. </template>
  8. <script>
  9. import {
  10. mapState,
  11. } from 'vuex'
  12. export default {
  13. name: 'flexLine',
  14. data() {
  15. return {
  16. navHeight: 0
  17. }
  18. },
  19. props: {
  20. backgroundColor: {
  21. type: String,
  22. default: ''
  23. }
  24. },
  25. computed: {
  26. ...mapState({
  27. config: state => state.config.config
  28. }),
  29. },
  30. methods: {
  31. },
  32. mounted: function() {
  33. // #ifdef MP-WEIXIN
  34. switch (uni.getSystemInfoSync().platform) {
  35. case 'android':
  36. this.navHeight = uni.getMenuButtonBoundingClientRect().top + 7
  37. break;
  38. case 'ios':
  39. this.navHeight = uni.getMenuButtonBoundingClientRect().top - 40
  40. break;
  41. default:
  42. this.navHeight = uni.getMenuButtonBoundingClientRect().top + 7
  43. break;
  44. }
  45. // #endif
  46. },
  47. }
  48. </script>
  49. <style scoped lang="scss">
  50. .navigation {
  51. padding-top:constant(safe-area-inset-top);
  52. padding-top:env(safe-area-inset-top);
  53. text-align: center;
  54. font-size: .7rem;
  55. background-color: #fff;
  56. }
  57. </style>