小程序是怎么计算rpx的?

发布于 7 年前作者 fxia3983 次浏览最后编辑 7 年前来自 issues

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

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

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

给 281px 和 281rpx 高度都不对

eyu
eyu3 楼5 年前