res.data.rules.forEach(function(item) { agtlValues += item.ruleNum + item.ruleValue + " "; ruleIds += item.id + ","; }); ruleIds = ruleIds.substring(0, ruleIds.lastIndexOf(","));
拼接" "可以换行展示
ruleIds+=item.id+",";是比较简洁的拼接;
substring(0,x);截取0到x的字符串;
lastIndexOf(",")最后一个逗号的下标;