最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

el-date-picker?限制開始時(shí)間和結(jié)束時(shí)間的代碼實(shí)現(xiàn)

 更新時(shí)間:2024年08月10日 14:21:23   作者:十一吖i  
在Vue.js中使用Element?UI庫的el-date-picker組件時(shí),可以通過設(shè)置picker-options來限制開始時(shí)間和結(jié)束時(shí)間的選擇范圍,下面通過例子介紹el-date-picker?限制開始時(shí)間和結(jié)束時(shí)間的實(shí)現(xiàn),感興趣的朋友一起看看吧

el-date-picker 限制開始時(shí)間和結(jié)束時(shí)間

需求:el-date-picker 月份限制開始時(shí)間和結(jié)束時(shí)間
開始時(shí)間:202307
結(jié)束時(shí)間:202407

代碼實(shí)現(xiàn)

vue 頁面

  <el-form-item label="月份" prop="monthList">
          <el-date-picker v-model="allForm.monthList" type="monthrange" range-separator="至" start-placeholder="開始月份"
            end-placeholder="結(jié)束月份" value-format="yyyy-MM" :picker-options="pickerOptions">
          </el-date-picker>
   </el-form-item>

script

<script>
export default {
 data() {
    return {
      allForm: {},
      allRules: {
        monthList: [
          { required: true, message: "日期不能為空", trigger: "blur" }
        ]
      },
      pickerOptions: {
        disabledDate(time) {
          const now = new Date()
          const year = now.getFullYear()
          const month = now.getMonth()
          // 去年當(dāng)前月份的前一個(gè)月
          const startYear = year - 1
          const startMonth = month === 0 ? 11 : month - 1
          const startDate = new Date(startYear, startMonth, 1)
          // 當(dāng)前月份的前一月
          const endYear = year
          const endMonth = month === 0 ? 11 : month - 1
          const endDate = new Date(endYear, endMonth, 1)
          return (
            time.getTime() < startDate.getTime() || time.getTime() > endDate.getTime()
          )
        }
      }
    }
  }
}
</script>

效果圖

在這里插入圖片描述

到此這篇關(guān)于el-date-picker 限制開始時(shí)間和結(jié)束時(shí)間的文章就介紹到這了,更多相關(guān)el-date-picker 限制時(shí)間內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

榆中县| 玉山县| 通州区| 高邑县| 陆河县| 奉新县| 贺州市| 高雄市| 金坛市| 烟台市| 石家庄市| 华池县| 兴文县| 广宗县| 垣曲县| 阜新市| 平南县| 金塔县| 江都市| 新巴尔虎左旗| 东台市| 柘荣县| 泊头市| 正宁县| 汉沽区| 安龙县| 玉溪市| 镶黄旗| 望谟县| 合肥市| 商都县| 遵义市| 兴安盟| 镇康县| 托克逊县| 武隆县| 车致| 子洲县| 诸暨市| 盐亭县| 辛集市|