微信小程序,uniapp,uview获得元素高度

微信小程序:

let query = wx.createSelectorQuery();
query.select('.find').boundingClientRect(res => {
    console.log(res.height);   // 1545.7249755859375
 }).exec();

 

uniap:

uni.getSystemInfo({
  success: function(res) { // res - 各种参数
     console.log(res.windowWidth); // 屏幕的宽度 

      let info = uni.createSelectorQuery().select(".类名");
      info.boundingClientRect(function(data) { //data - 各种参数
      console.log(data.width)  // 获取元素宽度
      }).exec()
       }
});

 

uview:

export default {
    methods: {
        async getElInfo() {
            let rectInfo = await this.$u.getRect('.类名');
            console.log(rectInfo);
        }
    }
}

 

 

 

 

转: 

https://v1.uviewui.com/js/getRect.html

https://blog.csdn.net/admin_web/article/details/117359984

https://www.csdn.net/tags/NtzaYg0sODgzODYtYmxvZwO0O0OO0O0O.html

 

posted @ 2022-04-14 14:25  与f  阅读(1419)  评论(0编辑  收藏  举报