兼容 ios
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { computed, type ComputedRef } from "vue";
|
||||
import { config } from "../config";
|
||||
import { rpx2px } from "@/cool";
|
||||
|
||||
/**
|
||||
* 字号管理类
|
||||
@@ -73,6 +74,35 @@ class Size {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取px值
|
||||
* @param val - 需要转换的值 10、10rpx、10px
|
||||
* @returns 转换后的px值
|
||||
*/
|
||||
getPxValue = (val: number | string) => {
|
||||
const scale = this.getScale();
|
||||
|
||||
if (typeof val == "string") {
|
||||
const num = parseFloat(val);
|
||||
const unit = val.replace(`${num}`, "");
|
||||
|
||||
if (unit == "px") {
|
||||
return num * scale;
|
||||
} else {
|
||||
return rpx2px(num * scale);
|
||||
}
|
||||
} else {
|
||||
return rpx2px(val * scale);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取px值
|
||||
*/
|
||||
getPx = (val: number | string) => {
|
||||
return this.getPxValue(val) + "px";
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取当前字号在预设中的索引
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user