使用 wx.getSystemInfo 获取设备信息
wx.getSystemInfo({
sucess(res){
// 获取屏幕宽度
let windowWidth = res.windowWidth;
// 逻辑像素转物理像素
let rpx = 200;
let px = rpx * windowWidth / 750;
// 物理像素转逻辑像素
let px2 = 15;
let rpx2 = px2 / 750 * windowWidth;
}
})