el-date-picker清空按钮
时间: 2023-09-25 16:15:14 浏览: 193
在el-date-picker组件中,清空按钮的实现方法是通过监听datepicker的times事件,当点击清空按钮时,times的值会变为null。具体的代码实现如下:
```html
<el-date-picker v-show="historyShow" ref="datePicker" v-model="times" style="margin-top:5px;" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" @change="handleHistoryTime" />
```
```javascript
// 监听times事件,当times的值为null时,执行清空操作
watch: {
times(val) {
if (!val) {
this.$refs.datePicker.showPicker();
this.times = [];
return;
}
}
}
```
你可以通过监听times事件来判断清空按钮是否被点击,并在事件中执行相应的操作。详情可以参考。另外,你也可以参考中的博客截图来获取更多相关信息。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [Element DatePicker 清空按钮点击不关闭日期选择框](https://blog.csdn.net/u011332271/article/details/127402859)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [el-date-picker 英文改中文.doc](https://download.csdn.net/download/xuelang532777032/44154571)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文