美文网首页
select 数字插件

select 数字插件

作者: 高磊_IT | 来源:发表于2020-12-24 10:22 被阅读0次
获取每月天数,并转化成数字
 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>

相关文章

网友评论

      本文标题:select 数字插件

      本文链接:https://www.haomeiwen.com/subject/nqnpnktx.html