var cups = [ { type: 1, price: 100, color: 'black', sales: 60, name: '牛客logo马克杯' }, { type: 2, price: 40, color: 'blue', sales: 100, name: '无盖星空杯' }, { type: 4, price: 60, color: 'green', sales: 200, name: '老式茶杯' }, { type: 3, price: 50, color: 'green', sales: 600, name: '欧式印花杯' } ] var select = document.querySelector('select'); var ul = document.querySelector('ul'); // 补全代码 let obj = { 0:()=>[].concat(cups), 1:()=>cups.filter(item=>item.sales<100), 2:()=>cups.filter(item=>item.sales>=100&&item.sales<=500), 3:()=>cups.filter(item=>item.sales>500) } select.onchange = function(e){ let srr = obj[select.value](); let len = srr.length; if(!len)return; let fragment = document.createDocumentFragment(); for(let i = 0; i<len;i++){ let li = document.createElement('li'); li.innerText = srr[i].name; fragment.appendChild(li) } ul.innerHTML = ''; ul.appendChild(fragment) }