elementUI表单嵌套时间报错

Posted on 2019-11-27 15:08  嗷呜~  阅读(610)  评论(0编辑  收藏  举报

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"
          }
        ],
}