如果非要手写的话,利用快捷键,有用请点采纳,谢谢
// html
<select id="selectYear"></select>
// js
var startYear= 1900;//起始年份
var endYear= new Date().getUTCFullYear();//终止年份(当前年份)
var obj = document.getElementById('selectYear')
onload = function () {
for (var i = startYear; i <= endYear; i++) {
obj.options.add(new Option(i, i))
};
obj.options[obj.options.length - 1].selected = 1
}
vue框架 可以使用v-for循环