/*计算当前Swiper的高度*/ getCurrentSwiperHeight() { //获取Dom是异步操作 所以封装Promise return new Promise((resolve, reject) => { let sum = 0; const query = uni.createSelectorQuery().in(this); query .selectAll(".swiper") .boundingClientRect((res) => { res.forEach((item, index) => { sum += item.height; console.log("循环:", index, "Height:", item.height); }) //成功传出去 resolve(sum); }) .exec(); }) }
标签:uniapp,index,res,sum,xxx,height,item,组件,query From: https://www.cnblogs.com/bi-hu/p/16840903.html