NavTitle.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div
  3. class="header"
  4. style="height:44px"
  5. :style="{ paddingTop: systemInfo.statusBarHeight + 'px', color: fontColor, backgroundColor: bgColor }"
  6. >
  7. <span class="name" :style="{ color: fontColor }"><slot></slot></span>
  8. <van-icon name="arrow-left" :size="24" :color="fontColor" @click="navigateBack" />
  9. </div>
  10. </template>
  11. <script>
  12. import { mapState } from 'vuex';
  13. export default {
  14. data() {
  15. return {
  16. colorType: 'light'
  17. };
  18. },
  19. computed: {
  20. ...mapState(['systemInfo']),
  21. fontColor() {
  22. if (this.colorType == 'light') {
  23. return '#fff';
  24. } else {
  25. return '#000';
  26. }
  27. }
  28. }
  29. };
  30. </script>
  31. <style lang="less" scoped>
  32. .header {
  33. top: 0;
  34. left: 0;
  35. right: 0;
  36. position: fixed;
  37. z-index: 100;
  38. transition: all ease-in-out 0.3s;
  39. padding: 0 15px;
  40. .flex();
  41. .name {
  42. padding: 0 100px;
  43. position: absolute;
  44. left: 0;
  45. right: 0;
  46. height: 44px;
  47. bottom: 0;
  48. font-size: 17px;
  49. line-height: 44px;
  50. text-align: center;
  51. z-index: 100;
  52. }
  53. ._van-icon {
  54. position: relative;
  55. z-index: 100;
  56. }
  57. }
  58. </style>