// 判断文字是否超过了一行
isLineWrap(text = "对列表进行") {
const getBLen = function (str) {
if (str == null) return 0;
if (typeof str != "string") {
str += "";
}
return str.replace(/[^\x00-\xff]/g, "01").length;
};
if (this.platform === "pc") {
const lineWidth = 334;
const textLine = getBLen(text) * 9.5;
return textLine > lineWidth;
} else {
const fontSizeSty = document.documentElement.style.fontSize;
const fontSize = Number(fontSizeSty.slice(0, fontSizeSty.length - 2));
const textLine = fontSize * getBLen(text) * 0.16;
const lineWidth = 4.56 * fontSize;
return textLine > lineWidth;
}
},
js判断文字是否 超过 一行(pc+h5)
最新推荐文章于 2024-05-30 19:22:33 发布