<el-date-picker v-model="ruleForm.dateValue"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions"
type="date"
size="small"
placeholder="选择日期">
data中定义:
ruleForm: { dateValue: "" },
定义timeDefault计算属性:
computed: {
timeDefault() {
var date = new Date();
var s1 = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate());
return s1;
}
},
//页面加载时候,在mounted中进行赋值
mounted() {
// 初始化查询,默认为前一天
this.ruleForm.dateValue = this.timeDefault;
}