utils.js 306 B

1234567891011
  1. const _screenWidth = uni.getSystemInfoSync().screenWidth;
  2. /**
  3. * rpx 单位转换为 px
  4. *
  5. * @param {number | string} rpx 待转换的数值
  6. * @returns number
  7. */
  8. export const rpx2px = (rpx, unit = false) => {
  9. const px = (_screenWidth * Number.parseFloat(rpx)) / 750;
  10. return unit ? `${px}px` : px;
  11. }