计算文字长度,我觉得英文大写也应该算作中文,尤其是W这的字再加粗的话很宽的

This commit is contained in:
马云海 mayunhai () 2019-03-01 09:41:48 +08:00
parent 9dd1456bb3
commit 344e95c57a
1 changed files with 1 additions and 1 deletions

View File

@ -98,7 +98,7 @@ export function getQueryObject(url) {
export function getByteLen(val) {
let len = 0
for (let i = 0; i < val.length; i++) {
if (val[i].match(/[^\x00-\xff]/gi) != null) {
if (val[i].match(/[^\x00-\xff]/gi) != null || (val[i] >= 'A' && val[i] <= 'Z')) {
len += 1
} else {
len += 0.5