js通过识别字符串中的逗号进行换行 let testInfo=['t1','t2','t3'] var str = testInfo.toString() var reg = /[,,]/g; str=str.replace(reg,"$&\r\n"); console.log(str);