uniapp,uview获得元素高度

前端 · 03-14

uniapp

uni.getSystemInfo({
  success: function(res) { // res - 各种参数
      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);
        }
    }
}

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

uniapp DOMDocument
Theme Jasmine by Kent Liao