<divclass="top"><el-selectv-model="year"clearableplaceholder="请选择年"><el-optionv-for="item in years":key="item":label="item":value="item"></el-option></el-select><el-selectv-model="month"clearableplaceholder="请选择月"><el-optionv-for="item in months":key="item":label="item":value="item"></el-option></el-select><el-selectv-model="day"clearableplaceholder="请选择月"><el-optionv-for="item in days":key="item":label="item":value="item"></el-option></el-select></div>
<script>exportdefault{name:"HospitalizationChargeDaily",data(){return{years:[''],months:[''],days:[''],year:'',month:'',day:'',};},created(){this.initDate();},watch:{month:function(){if(((this.year %4===0&&this.year %100!==0)||this.year %400===0)&&this.month ===2){this.days =[""];for(let i =1; i <=29; i++)this.days.push(i);}else{if(this.month ===1||this.month ===3||this.month ===5||this.month ===7||this.month ===8||this.month ===10||this.month ===12){this.days =[""];for(let i =1; i <=31; i++)this.days.push(i);}elseif(this.month ===2){this.days =[""];for(let i =1; i <=28; i++)this.days.push(i);}else{this.days =[""];for(let i =1; i <=30; i++)this.days.push(i);}}},},methods:{initDate(){let currentyear =newDate().getFullYear();for(let i = currentyear -5; i <= currentyear +5; i++){this.years.push(i);}for(let i =1; i <=12; i++){this.months.push(i)}for(let i =1; i <=31; i++){this.days.push(i);}},},};</script>