//计算字符串长度包含中文 function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; } else { len += 1; } } return len; } function a(val,num){ let arr = [] for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { arr.push(a,'') } else { arr.push(a) } } return arr.filter((v,i)=>i<num).join(''); } console.log(a('123啊阿斯顿发3',7))