elementUI表单嵌套日期时间选择时间后报错
<el-form-item label="起始结束时间:" required prop="startime"> <el-date-picker size="small" v-model="form.startime" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @change="delaySearch" ></el-date-picker> </el-form-item>
"TypeError: dateObject.getTime is not a function"
原因:
rules中type:'date'造成的,因为初始化成了string类型。修改 type 类型即可
rules: { startime: [ { // type: "date", required: true, message: "请选择起始时间", trigger: "change" } ], }