//wxml
<swiper style="height: {
{ swiperHeight }}">
<swiper-item class="myswiperitem">
<view class="deh">swiper美容</view>
</swiper-item>
</swiper>
//js
data:{ swiperHeight:'' }
// 获取内容的高度
this.getHeight('deh')
getHeight(str) { //根据不同的类名,去获取不同的内容高度
// 获取元素高度
let query = wx.createSelectorQuery();
//选择id
let that = this;
query.select('.' + str).boundingClientRect(function (rect) {
that.setData({
swiperHeight: rect.height + 20 + 'px'
})
}).exec();
},
微信小程序的swiper插件自适应内容的高度
猜你喜欢
转载自blog.csdn.net/qq_41687299/article/details/122229085
今日推荐
周排行