小程序获取view控件的宽度或者高度

版权声明:本文为楠之枫雪的原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014614038/article/details/82020680
   //创建节点选择器
    var query = wx.createSelectorQuery();
    //选择id
    var that = this;
    query.select('.text').boundingClientRect(function (rect) {
       console.log(rect.width)
    }).exec();

wxml中:

 <view class='text'style='left:{{offsetLeft}}px' >{{text}}</view>

猜你喜欢

转载自blog.csdn.net/u014614038/article/details/82020680