微信小程序获取image标签的宽和高?
发布于 5 年前 作者 yangyan 2066 次浏览 来自 官方Issues

微信小程序中如何获取image标签的宽和高?

1 回复

    let query = wx.createSelectorQuery();

    let that = this;

    query.select(’#图片id’).boundingClientRect(function (rect) {

      that.setData({

        height: rect.height + ‘px’, //图片高

        width: rect.width + ‘px’ //图片宽

      })

    }).exec();

希望该回答有用

回到顶部