<template> <!-- <el-form-item label="日期"> <el-input v-model="listQuery.beanName" class="width300" placeholder="请输入类名"></el-input> <el-date-picker v-model="listQuery.day" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"> </el-date-picker> </el-form-item> --> <div class="workday"> <el-date-picker v-model="dayData" type="date" placeholder="选择日期" @change="dataChange(dayData)" /> <div>{{week}}</div> </div> </template> <script> export default { components: {}, data() { return { dayData: '', //日期 week: '', //星期 } }, created() {}, mounted() { }, watch: {}, computed: {}, methods: { dataChange(value){ var weekday = new Array(7); weekday[0] = "周日"; weekday[1] = "周一"; weekday[2] = "周二"; weekday[3] = "周三"; weekday[4] = "周四"; weekday[5] = "周五"; weekday[6] = "周六"; console.log(weekday[value.getDay()], '=---======------') var shift = new Date(value); //把标准时间转换成正常时间 this.dayData = shift.getFullYear() + '-' + (shift.getMonth() + 1) + '-' + shift.getDate(); //赋值给日期-传值给后台-因传值需要正常日期 this.week = weekday[value.getDay()]; //周几 alert(this.dayData) alert(this.week) }, }, } </script> 只显示日期 <el-date-picker format="MM-dd" value-format="MM-dd" v-model="form.autumnTime" type="date" placeholder="选择日期"> </el-date-picker>