let data=[{label: '默认'}, {label: '默认1'}, {label: '默认2'}] function getLabel(label) { let last = label[label.length - 1]; while (data.find(a => a.label === label)) { if (!isNaN(last)) { console.log('in', last, label) last = Number(last) + 1; label = label.substr(0, label.length - 1) + last } else { label = label + '1'; } last = label[label.length - 1]; } return label; }