关于uview tabs切换高度适应问题

刚开始用的时候只能自定义高度,那么超出高度的内容就会被斩断,所以需要获取一下当前高度来自定义

<swiper :style="{
        'height': scrollHeight+'px'}" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" style="height: 1050upx;">
				<swiper-item class="swiper-item" v-for="(item, index) in list" :key="index">
					<scroll-view class="scrollbox" scroll-y @scrolltolower="onreachBottom" :style="{
        'height': scrollHeight+'px'}" >
						<view v-if="item.order==1" >
							1111
						view>
						<view v-if="item.order==2">
							222
						<view v-if="item.order==3">
							333
						view>
					scroll-view>
				swiper-item>
			swiper>
export default {
     
		data() {
     
			return {
     
			scrollHeight:'',
			}
		}mounted(){
     
			let that = this;
			let info = uni.createSelectorQuery().select(".scrollbox");
			info.boundingClientRect(function(data) {
      //data - 各种参数
			//       console.log(data.height)  // 获取元素宽度
			that.scrollHeight = data.height+10
			}).exec()
			console.log(that.scrollHeight)
		},
	}

你可能感兴趣的:(前端)