el-date-picker 回显
时间: 2023-08-18 11:09:08 浏览: 209
el-date-picker组件的回显可以通过v-model指令绑定数据实现。在Vue的实例中,给v-model绑定一个变量,该变量的值会自动同步到el-date-picker组件中。当需要回显数据时,只需要将数据赋值给v-model绑定的变量,el-date-picker组件就会显示相应的日期。具体实现可以参考以下代码:
```html
<el-date-picker v-model="date" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd"></el-date-picker>
```
```javascript
data() {
return {
date: '' // 初始化变量
}
},
methods: {
showDate(row) {
this.date = row.date; // 将回显的日期赋值给date变量
}
}
```
在上述代码中,v-model指令绑定的变量为date,当需要回显日期时,只需将相应的日期赋值给date变量,el-date-picker组件就会显示该日期。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [【VUE】el-date-picker日期选择器回显](https://blog.csdn.net/liusuihong919520/article/details/126890074)[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* [Element el-date-picker表单校验和数据回显问题](https://blog.csdn.net/Web_chicken/article/details/120073888)[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* [Vue 日期控件(el-date-picker)回显异常及其原理分析](https://blog.csdn.net/vipshop_fin_dev/article/details/108367899)[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 ]
阅读全文