el-date-picker选择多年
时间: 2023-08-09 21:08:08 浏览: 102
el-date-picker 英文改中文.doc
5星 · 资源好评率100%
el-date-picker可以选择多年的功能可以通过设置type属性为"yearrange"来实现。在模板中,可以使用以下代码来实现el-date-picker选择多年的功能:
```html
<el-date-picker ref="picker" v-model="pickDataList" type="yearrange" :picker-options="pickerOptions" value-format="yyyy" start-placeholder="开始年份" end-placeholder="结束年份" @change="getRoomCheckInRecordList"></el-date-picker>
```
在data中定义pickDataList和pickerOptions属性,如下所示:
```javascript
data() {
return {
pickDataList: '', // el-date-picker v-model的值
pickerOptions: {
onPick: this.getPickDate,
disabledDate: this.disabledDate
}
}
},
```
同时,需要在methods中定义getPickDate和disabledDate方法,如下所示:
```javascript
methods: {
getPickDate(date) {
// 处理选择日期的逻辑
},
disabledDate(time) {
// 处理禁用日期的逻辑
}
}
```
这样,el-date-picker就可以选择多年了。
#### 引用[.reference_title]
- *1* *2* [处理Element 日期选择器el-date-picker 限制时间跨度一年](https://blog.csdn.net/qq_37831545/article/details/125522722)[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^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [el-elementUI使用el-date-picker,选择年,选择月](https://blog.csdn.net/weixin_44986077/article/details/110817879)[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^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文