elementUI :Cannot read property 'getHours' of undefined
程序员文章站
2022-03-04 11:03:02
...
DateTimePicker 日期时间选择器报错:Cannot read property ‘getHours’ of undefined
方法一:(需要默认值时)
场景(type是datetime):例
<el-form-item label="无效的时间:">
<el-date-picker
v-model="pointEnd"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
....
pointEnd:"2019-03-22"
上面这种就会报错,改pointEnd:"2019-03-22 00:00:00"后,依然还是有错,这时候给加属性表明你的时间格式:
value-format="yyyy-MM-dd HH:mm:ss"
<el-form-item label="无效的时间:">
<el-date-picker
v-model="pointEnd"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
....
pointEnd:"2019-03-22 00:00:00"
这样问题解决。
方法一:(没有默认时间,不需)
<el-form-item label="无效的时间:">
<el-date-picker
v-model="pointEnd"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
....
pointEnd:null
直接给初始值null,也可解决
推荐阅读
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object
-
npm ERR! Cannot read property 'path' of null
-
js报错 Cannot read property 'getAttribute' of null
-
微信小程序报Cannot read property 'setData' of undefined的错误
-
webpack报错Cannot read property 'presetToOptions' of undefined
-
Extjs4---Uncaught TypeError: Cannot read property ‘items’ of undefined
-
JavaScript Uncaught TypeError: Cannot read property 'value' of null
-
Cannot read property 'tap' of undefined
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#
-
el-tooltip组件中content使用Vue-i18n报错TypeError: Cannot read property ‘$t‘ of null