elementUI时间选择器:TypeError: value.getHours is not a function
elementUI时间选择器:TypeError: value.getHours is not a function
使用elementUI的日期时间选择控件报错
element-ui时间控件报错:TypeError: date.getHours is not a function、TypeError: date.getFullYear is not a function、TypeError: value.getTime is not a function
分析:
- 原因是:https://blog.csdn.net/wy6250000/article/details/87879363
日期选择器【el-date-picker】加了格式 value-format=“yyyy-MM-dd” format=“yyyy-MM-dd”
和校验规则:{ type: ‘date’, required: true, message: ‘请选择日期’, trigger: ‘change’ }后,结果报错
解决方法:将校验规则中的 type: ‘date’,改成 type: ‘String’。
可能是在转换格式后,绑定的值是String类型,而不是Date对象,所以校验规则无法识别
- 格式问题:https://blog.csdn.net/weixin_45422787/article/details/119145651
解决后的代码format不可以有,不然会在选择的时候导致格式不一致。
- 格式问题
解决:date的初始值是空字符串