back.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="back" :style="'height:'+capsuleHeight+ 'px;top:'+capsuleHighly+'px;'">
  3. <!-- <view class="t-icon t-icon-fanhui2-copy" @click="backIconHandler"></view> -->
  4. <u-icon name="arrow-left" color="#000000" size="18" @click="backIconHandler"></u-icon>
  5. <view class="back-text">
  6. {{ text }}
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. name: "back",
  13. props:{
  14. text:{
  15. type:String,
  16. default:''
  17. }
  18. },
  19. data() {
  20. return {
  21. //胶囊高度
  22. capsuleHeight: 0,
  23. //
  24. capsuleHighly: 0,
  25. };
  26. },
  27. created() {
  28. this.getCapsuleSite()
  29. },
  30. methods:{
  31. backIconHandler(){
  32. //调用自定义事件
  33. // this.$emit('click')
  34. uni.navigateBack()
  35. },
  36. //获取胶囊位置信息
  37. getCapsuleSite(){
  38. let res=uni.getMenuButtonBoundingClientRect()
  39. console.log(res)
  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. .t-icon {
  53. width: 45rpx;
  54. height: 45rpx;
  55. }
  56. .back-text{
  57. font-size: 48rpx;
  58. margin-left: 20rpx;
  59. }
  60. }
  61. </style>