效果图:
代码部分:
<el-row style="margin: 10px 0 0 10px" type="flex" justify="left"> <el-form :model="queryCondition" ref="refQueryCondition" label-width="auto" style="width:100%;"> <el-col style="margin-left: 10px" :span="4"> <el-form-item label="时间:" prop="startDate" > <el-date-picker v-model="queryCondition.queryDate" type="date" placeholder="选择日期" style="width:170px;"> </el-date-picker> </el-form-item> </el-col> <el-col :span="4"> <el-button type="primary" @click="loadList()">查询</el-button> <el-button type="primary" @click="sumbitData()">提交</el-button> </el-col> </el-form> </el-row>
<span style="font-size: 18px">{{ nowYear }}年{{ nowMonth }}月{{ nowDay}}日{{ nowDate }}</span>
data(){ return{ queryCondition:{ queryDate:''//查询时间 }, nowDate:'',//当前时间格式: 2023-05-08 nowYear:'',//当前月 nowMonth:'',//当前年 nowDay:'',//当前日 } },
created() { const newDate = { year: new Date().getFullYear(), month: new Date().getMonth() + 1, date: new Date().getDate(), } this.nowYear = newDate.year //当前年 this.nowMonth = newDate.month > 10 ? newDate.month : "0" + newDate.month; //当前月:0X this.nowDay = newDate.date > 10 ? newDate.date : "0" + newDate.date; //当前日:0X this.nowDate =this.nowYear +"-" +this.nowMonth+"-" +this.nowDay //当前时间格式: 2023-05-08 this.queryCondition.queryDate=this.nowDate //显示在输入框中 },