1,html
<el-form-item label="预算年度">
<el-select
v-model="formselect.year"
placeholder="请选择"
filterable
class="searchfilter"
style="height: 32px; line-height: 32px; width: 150px"
>
<el-option
v-for="item in years"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
2, js
1,加载
created() {
var myDate = new Date();
var year = myDate.getFullYear(); //获取当前年
this.initSelectYear(year);
},
2,方法
initSelectYear(year) {
this.years = [];
for (let i = 0; i < 30; i++) {
this.years.push({ value: year - i, label: year - i + "年" });
}
},
网友评论