wanan-01

页面wxml

<!--page/index/index.wxml-->
<view id=\'demo\'>
    <text>哈哈哈哈哈</text>
    <view>哈哈哈哈哈</view>
</view>

js文件

onLoad: function(options) {
        //创建节点选择器
        var query = wx.createSelectorQuery();
        //选择id
        query.select(\'#demo\').boundingClientRect()
        query.exec(function(res) {
            //res就是 所有标签为mjltest的元素的信息 的数组
            console.log(res);
            //取高度
            console.log(res[0].height);
        })
    },

结果:

这里获取的高度可以是设置好的,也可以是没有设置,自动撑开的高度。

分类:

技术点:

相关文章:

  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-12-25
  • 2021-09-15
猜你喜欢
  • 2022-12-23
  • 2022-01-07
  • 2021-10-04
  • 2021-11-14
  • 2021-12-25
  • 2021-12-25
相关资源
相似解决方案