小程序是怎么计算rpx的?
发布于 5 年前 作者 fxia 3755 次浏览 来自 官方Issues

小程序动态获取的元素高度是数字类型,单位是什么呢,如果要转为rpx该怎么计算呢?

3 回复
const query = wx.createSelectorQuery();
query.select('.page').boundingClientRect(function (res){
  //res.height   单位 px 转换成 rpx  * 2  然后单位写rpx即可
  console.log(res.height * 2);
}).exec();

高度计算 336-55=281 是number类型 是什么单位呢

给 281px 和 281rpx 高度都不对

回到顶部