Skip to content

引入

ts
import { transFormRem } from 't-comm';

// 不支持 tree-shaking 的项目
import { transFormRem} from 't-comm/lib/rem/index';

// 只支持 ESM 的项目
import { transFormRem} from 't-comm/es/rem/index';

transFormRem(content, factor, unit)

描述

转化 rem 单位

参数

参数名类型描述
contentstring

输入内容

factornumber

转化比例,默认 100

unitstring

转化单位,默认 rpx

返回: string

转化后的结果

示例

ts
transFormRem('1.22rem')
// 122rpx

transFormRem('1.22rem', 50, 'px')
// 61px

transFormRem('.21rem', 50, 'px')
// 10.50px