获取每月天数,并转化成数字
async getDaysInMonth(year: any, month: any) {
let temp = new Date(year, month, 0);
let nums = temp.getDate(); //计算出当月天数
let i = 0;
const getNum = new Array(nums).fill(i++);
for (let index = 0; index < getNum.length; index++) {
this.getDays.push({
index: index,
value: index,
label: index + 1,
});
if (index === 0) {
//去除数组第一个对象
this.getDays.shift();
}
if (index === getNum.length - 1) {
//在数组最后面追加一个对象
this.getDays.push({
index: index + 1,
value: "End",
label: "End",
});
}
}
}
<el-select v-model="form.executeDay" multiple placeholder="请选择" popper-class="dayStyle">
<el-option v-for="item in getDays" :key="item.index" :label="item.label" :value="item.label">
</el-option>
</el-select>
<style>
.is-multiple .el-select-dropdown__item {
width: 80px;
float: left;
margin-left: 8px;
}
.dayStyle {
width: 360px !important;
float: left;
}
</style>
网友评论