标签:ret color i++ pre class ring profile sub 截取字符串
// 截取简介字符串为20个字 getProfileCharCode =(val) => { let newVal = ‘‘; let zLen = 0; let eLen = 0; if(val) { for (let i = 0; i < val.length; i++) { let a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { zLen += 2; } else { eLen += 1; } } if(((zLen / 2) + eLen) >= 20) { newVal = val.substring(0, 20) + ‘...‘; }else { newVal = val; } } return newVal; }
标签:ret color i++ pre class ring profile sub 截取字符串
原文地址:http://www.cnblogs.com/lqcdsns/p/6247444.html