back.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="back" :style="{height: capsuleHeight+ 'px',top:capsuleHighly+'px'}">
  3. <u-icon name="arrow-left" :color="color" size="24" @click="backIconHandler"></u-icon>
  4. <view class="back-text" :style="{color: color}">
  5. {{ text }}
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: "back",
  12. props:{
  13. text:{
  14. type:String,
  15. default:''
  16. },
  17. color:{
  18. type:String,
  19. default:'#3B4144'
  20. }
  21. },
  22. data() {
  23. return {
  24. //胶囊高度
  25. capsuleHeight: 0,
  26. //
  27. capsuleHighly: 0,
  28. };
  29. },
  30. created() {
  31. this.getCapsuleSite()
  32. },
  33. methods:{
  34. backIconHandler(){
  35. uni.navigateBack()
  36. },
  37. //获取胶囊位置信息
  38. getCapsuleSite(){
  39. let res=uni.getMenuButtonBoundingClientRect()
  40. this.capsuleHeight = res.height
  41. this.capsuleHighly = res.top
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss">
  47. .back {
  48. position: relative;
  49. padding: 0 0 120rpx 20rpx;
  50. display: flex;
  51. align-items: center;
  52. z-index: 99;
  53. .t-icon {
  54. width: 35rpx;
  55. height: 35rpx;
  56. }
  57. .back-text{
  58. font-size: 40rpx;
  59. margin:0 0 6rpx 20rpx;
  60. }
  61. }
  62. </style>