获取当前设备的宽度,单位PX
常用与移动端开发中单位的计算
px2rpx
import { device } from 'onex-utils'; const { getDeviceWidth } = device; export function px2rpx(source, width: number) { const scale = 750 / width; return `${getDeviceWidth() * scale}rpx`; }
rpx2px
import { device } from 'onex-utils'; const { getDeviceWidth } = device; export function rpx2px(source, width: number) { const scale = 750 / width; return `${getDeviceWidth() / scale}px`; }
获取当前设备的宽度,单位PX
常用与移动端开发中单位的计算
px2rpx
rpx2px