el-time-picker报错typeError: Cannot read properties of undefined (reading 'getHours')
时间: 2023-08-25 16:14:01 浏览: 679
vue-ctk-date-time-picker:VueJS组件选择日期和时间,包括范围模式
5星 · 资源好评率100%
这个报错通常是因为在使用el-time-picker组件时,绑定的数据格式不正确所导致的。根据引用中的解决方法,你需要确保绑定的数据是一个字符串类型。在你的代码中,将日期的初始值从数组形式改为一个空字符串,即将`addForm.selectDates: []`改为`addForm.selectDates: ''`。这样就可以解决这个报错了。
参考文献:
https://blog.csdn.net/qq_38194393/article/details/90690611?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task.<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [Vue: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘hour‘)](https://blog.csdn.net/weixin_51146503/article/details/127179923)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *2* [Vue Element UI 之 date-picker 禁用时间和报错:TypeError: Cannot read property 'getHours' of undefined](https://blog.csdn.net/qq_41956139/article/details/105226336)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *3* [使用Element-UI的DateTimePicker组件报错:Cannot read property 'getHours' of undefined](https://blog.csdn.net/xi_nuo/article/details/90040794)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文