el-elementUI使用el-date-picker,选择年,选择月
vue中使用el-date-picker选择年<el-date-pickerv-model="gysForm.year"type="year"placeholder="选择日期"format="yyyy"value-format="yyyy"style="width: 100%;":picker-options=
·
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>
更多推荐
已为社区贡献8条内容
所有评论(0)