// px转rpx
export const pxTorpx = (value: number) => {
const systemInfo: any = uni.getSystemInfoSync()
if(!value || typeof(value) !== 'number') {
return value
}
// 1rpx 对应的px值
const scale = systemInfo.screenWidth / 750
return Math.floor(value / scale)
}
// rpx转px
export const rpxTopx = (value: number) => {
const systemInfo: any = uni.getSystemInfoSync()
if(!value || typeof(value) !== 'number') {
return value
}
// 1rpx 对应的px值
const scale = systemInfo.screenWidth / 750
return Math.floor(scale * value)
}
1 个回复
Luoxue