Skip to content

Functions

pxToRem()

pxToRem(value, options): string

数值由 px 转为 rem 并携带单位

Parameters

ParameterTypeDescription
valuenumber数值
optionsPxToRemOptions配置项

Returns

string

Example

ts
pxToRem.defaults = {
  precision: 4,
}
document.documentElement.style.fontSize = '100px'

pxToRem(100)
// => '1rem'

Interfaces

PxToRemOptions

Properties

PropertyTypeDescription
forceUpdateRootFontSize?boolean是否强制更新根字体大小 Default false
precision?number小数精度 Default 6

Namespaces