vue中使用el-date-picker选择年

在这里插入图片描述


  <el-date-picker
            v-model="gysForm.year"
            type="year"
            placeholder="选择日期"
            format="yyyy"
            value-format="yyyy"
            style="width: 100%;"
            :picker-options="pickerOptions"
          />

data(){
	return{
		gysForm:{
			year:''
		}
	}
},

methods:{
	 pickerOptions: {
      //disabled为函数,返回值为布尔值,
      disabledDate: (time) => {
        let minYear = new Date().getFullYear() - 30
        return time > Date.now() || time.getTime() < new Date(JSON.stringify(minYear))
      }
    },
}

选择年月

在这里插入图片描述

<el-date-picker v-model="selectMonth" type="month" placeholder="选择月"   @change="jobSearch" value-format="yyyy-MM"></el-date-picker>


<script>
export default {
    data() {
         return {
            selectMonth:''
        }
    },
    created() {
        this.initData({});
    },
    methods: {
        jobSearch() {
      this.getJobListByMonth();
    },
    async initData(data) {
      //获取当前时间
      var now   = new Date();
      var monthn = now.getMonth()+1;
      var yearn  = now.getFullYear();
      this.selectMonth = yearn+"-"+monthn;
 
      this.selectUser = parseInt(sessionStorage.getItem("userid"));
      // this.getWeekJobList({
      //   userid: sessionStorage.getItem("userid"),
      //   weekid: "1"
      // });
      this.getJobListByMonth();
    },
    async getJobListByMonth(data) {
 
    }
   }
}
</script>
Logo

前往低代码交流专区

更多推荐