// 处理超出字后面... export function doStr(str, n) { let totalCount = 0; let txt = ""; if (str) { for (var i = 0; i < str.length; i++) { let c = str.charCodeAt(i); if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) { totalCount++; } else { totalCount += 2; } if (totalCount <= n) { txt += str[i]; } else { txt += '...'; return txt } } } return txt; }