在uniapp中使用swiper必须要设置高度,一般都是动态设置。
一种是 高度 * 数量,这里不做详解。
另一种是 swiper + scroll-view 组合,获取系统高度 在此高度中滑动,这里要说的就是第二种。
swiper 绑定一个高度
在swiper-iteam下嵌套scroll-view,并设置scroll-view的高度为100%
.scrol{
height: 100%;
}
在js中设置swiper的高度
data(){
return{
swiperHeight:''
}
}
onLoad() {
uni.getSystemInfo({ //获取系统信息
success: (res) => {
this.swiperHeight = res.windowHeight + 'px'
},
fail: (res) => {
console.log('error')
}
})
}