美文网首页
uniapp中获取dom元素宽度、高度

uniapp中获取dom元素宽度、高度

作者: 可乐_加冰_ | 来源:发表于2023-07-23 11:48 被阅读0次
     let info = uni.createSelectorQuery().select(".info-box");
                        info.boundingClientRect(function(data) { //data - 各种参数
                            //readonly bottom: number;
                            // readonly height: number;
                            // readonly left: number;
                            // readonly right: number;
                            // readonly top: number;
                            // readonly width: number;
                            // readonly x: number;
                            // readonly y: number;
                            that.setWebviewHeight(parseInt(data.height))
                            console.log('元素高度为--->>',parseInt(data.height)) // 获取元素宽度
                        }).exec()
    

    相关文章

      网友评论

          本文标题:uniapp中获取dom元素宽度、高度

          本文链接:https://www.haomeiwen.com/subject/awmfpdtx.html