1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <template>
- <view class="back" :style="{height: capsuleHeight+ 'px',top:capsuleHighly+'px'}">
- <u-icon name="arrow-left" v-if="show" :color="color" size="24" @click="backIconHandler"></u-icon>
- <u-icon name="home-fill" v-if="!show" :color="color" size="24" @click="backHomeHandler"></u-icon>
- <view class="back-text" :style="{color: color}">
- {{ text }}
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "back",
- props:{
- text:{
- type:String,
- default:''
- },
- color:{
- type:String,
- default:'#3B4144'
- },
- show:{
- type:Boolean,
- default: true
- }
- },
- data() {
- return {
- //胶囊高度
- capsuleHeight: 0,
- //
- capsuleHighly: 0,
- };
- },
- created() {
- this.getCapsuleSite()
- },
- methods:{
- backIconHandler(){
- uni.navigateBack()
- },
- backHomeHandler(){
- uni.switchTab({
- url: '/pages/home/home'
- })
- },
- //获取胶囊位置信息
- getCapsuleSite(){
- let res=uni.getMenuButtonBoundingClientRect()
- this.capsuleHeight = res.height
- this.capsuleHighly = res.top
- }
- }
- }
- </script>
- <style lang="scss">
- .back {
- position: relative;
- padding: 0 0 120rpx 20rpx;
- display: flex;
- align-items: center;
- z-index: 99;
- .t-icon {
- width: 35rpx;
- height: 35rpx;
- }
-
- .back-text{
- font-size: 40rpx;
- font-weight: bold;
- margin:0 0 6rpx 20rpx;
- }
- }
- </style>
|