function(str,num){
var len=str.length
if(str.replace(/[\u4e00-\u9fbf]/g,'**').length <= num){
return str;
}
while(str.replace(/[\u4e00-\u9fbf]/g,'**').length > num){
str = str.slice(0,len--)
}
return str+'...'
}
转载于:https://www.cnblogs.com/xiaohui108/p/4052858.html