//使用纯JavaScript的遍历数组的方法.forEach(),有三个参数:item,index,arry module.forEach(function (item){ let optionText = item.summarize; let option = $('<option>').text(optionText); $('#dropDownName').append(option); });
//使用jQuery的遍历数组的方法$.each(),有两个参数:index,value $.each(module,function (index,value){ select.append($('<option></option>').text(value.summarize)); console.log($('<option></option>').text(value.summarize)); });
遍历的方法还有很多,这两种常见一些吧,不同的遍历方法参数有的也不一样,具体看个人使用