Skip to content

Functions ​

scalePx() ​

scalePx(value, options): number

数值由 px 基于当前视口大小和设计稿大小的比例进行缩放

Parameters ​

ParameterTypeDescription
valuenumber数值
optionsScalePxOptions配置项

Returns ​

number

Example ​

ts
scalePx.defaults = {
  mode: 'width',
  designWidth: 1920,
  precision: 6,
}

scalePx(100)
// => +((window.innerWidth / 1920) * 100).toFixed(6)

Interfaces ​

ScalePxOptions ​

Properties ​

PropertyTypeDescription
designHeight?number设计稿高度 Default 1080
designWidth?number设计稿宽度 Default 1920
excludeScrollbar?boolean获取窗口大小进行计算时是否排除滚动条大小 Default false
mode?ScalePxMode缩放模式 Default 'width'
precision?number小数精度 Default 6

Namespaces ​

Type Aliases ​

ScalePxMode ​

ScalePxMode = "width" | "height"