1
0

back.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view>
  3. <view class="back" :style="{ paddingTop: top + 'px' }">
  4. <view class="cont">
  5. <text class="icon" @click="back()">&#xe8ef;</text>
  6. <text class="title">{{ title }}</text>
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'back',
  14. props: {
  15. title: {
  16. type: String,
  17. default: ''
  18. }
  19. },
  20. data() {
  21. return {
  22. top: 0,
  23. mb: 140
  24. };
  25. },
  26. mounted() {
  27. uni.getSystemInfo({
  28. success: res => {
  29. this.top = parseInt(res.safeArea.top) - 5;
  30. // #ifdef MP-WEIXIN
  31. this.mb = this.mb - this.top + 10;
  32. // #endif
  33. // #ifdef H5
  34. this.mb = this.mb - this.top;
  35. // #endif
  36. },
  37. fail(err) {
  38. console.error(err);
  39. }
  40. });
  41. },
  42. methods: {
  43. back() {
  44. uni.navigateBack();
  45. }
  46. }
  47. };
  48. </script>
  49. <style lang="scss">
  50. .back {
  51. position: fixed;
  52. top: 0px;
  53. width: 100%;
  54. height: 50px;
  55. text-align: center;
  56. color: white;
  57. z-index: 11111;
  58. .cont {
  59. padding: 15px 0px 15px 0px;
  60. position: relative;
  61. .icon {
  62. position: absolute;
  63. font-size: 25px;
  64. left: 10px;
  65. }
  66. .title {
  67. font-size: 16px;
  68. font-weight: bold;
  69. }
  70. }
  71. }
  72. .top {
  73. image {
  74. width: 100%;
  75. }
  76. }
  77. </style>