js数组拼接成字符串,去除最后一个逗号
res.data.rules.forEach(function(item) { agtlValues += item.ruleNum + item.ruleValue + " \n"; ruleIds += item.id + ","; }); ruleIds = ruleIds.substring(0, ruleIds.lastIndexOf(","));
拼接"\n"可以换行展示
ruleIds+=item.id+",";是比较简洁的拼接;
substring(0,x);截取0到x的字符串;
lastIndexOf(",")最后一个逗号的下标;
看到我的div了吗?在你那你就完蛋了