首页 > 其他分享 >uniapp 计算当前xxx组件高度

uniapp 计算当前xxx组件高度

时间:2022-10-30 12:12:21浏览次数:55  
标签:uniapp index res sum xxx height item 组件 query

 /*计算当前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

相关文章