el-date-picker月选择器获取选择的日期范围

<el-date-picker
          v-model="monthValue"
          type="month"
          placeholder="选择月"
          value-format="yyyy-MM-dd"
          @change="monthChange"
        >
</el-date-picker>
​
   
   monthChange(val) {
      const [year, month, day] = val.split('-') // 获取对应的年月日
      const endDate = new Date(year, month, 0).getDate() // 获取对应的年所在月有多少天
      let res = [`${year}-${month}-${day}`, `${year}-${month}-${endDate}`]
      console.log(res)
  },

猜你喜欢

转载自blog.csdn.net/m0_74149462/article/details/135214885