...
|
...
|
@@ -10,7 +10,7 @@ let stringHandle = { |
|
|
* 汉字相当于两个字符的字符串长度计算
|
|
|
* @param {*} str
|
|
|
*/
|
|
|
chinese2(str) {
|
|
|
chinese2: function(str) {
|
|
|
let total = 0,
|
|
|
charCode,
|
|
|
i,
|
...
|
...
|
@@ -26,13 +26,12 @@ let stringHandle = { |
|
|
}
|
|
|
return total;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 中文相当于两个字符情况下的字符串截取
|
|
|
* @param {*} str
|
|
|
* @param {*} n
|
|
|
*/
|
|
|
sub_chinese2(str, n) {
|
|
|
sub_chinese2: function(str, n) {
|
|
|
let r = /[\u4E00-\u9FA5]/g;
|
|
|
|
|
|
if (str.replace(r, 'mm').length <= n) {
|
...
|
...
|
|