自适应的100%完美解决方案"/>
uniapp swiper高度自适应的100%完美解决方案
onReady() {//swiper高度自适应this.getElementHeight('.swiper-item2')},methods:{getElementHeight(element) {setTimeout(()=>{let query = uni.createSelectorQuery().in(this);query.select(element).boundingClientRect();query.exec((res) => {if (!res) {//如果没获取到,再调一次this.getElementHeight();}else {this.swiperHeight = res[0].height;}})},20)},
通过setTimeOut设置高度,但好像存在获取不到的场景,因此判断空重新递归调用
更多推荐
uniapp swiper高度自适应的100%完美解决方案
发布评论