布局一下高度为动态的
<swiper
class="swiper"
:style="{height: windowHeight + 'px'}"
:current="currentTab"
@change="onSwiperChange">
<swiper>
data() {
return {
windowHeight: '', // 页面高度
}
},
methods:{
init() {
const res = uni.getSystemInfoSync();
this.windowHeight = res.windowHeight;
}
}
this.$nextTick(() => {
//获取节点代码
var query = uni.createSelectorQuery();
//获取节点
query.select(`.news-box-${currentTab}`).boundingClientRect(res => {
//判断是否未true
if (res) {
//当前元素高度
this.windowHeight = res.height;
//页面高度+循环体高度等于总高度
}
}).exec();
})