back.vue 1.0 KB

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