1.截取前面所有的字符
let a = 'shangwu,xiawu';
let b = a.indexOf(',');
let c = a.substring(0,b)
console.log(c);
2.截取后面所有的字符
let h = 'shangwu,xiawu';
let s = h.split(',');
console.log(s,'不加下标返回数组');
console.log(s[1],'获取想要的字符')
本文链接:https://my.lmcjl.com/post/4045.html
展开阅读全文
4 评论