https://www.antdv.com/docs/vue/faq-cn/
代码实现:
当前需要对组件a-date-picker进行改造,如下:
html:
<a-date-picker
mode="year"
format="YYYY"
:value="state.time"
:open="state.isopen"
placeholder="请选择年份"
@focus="changeopen"
@panelChange="handlePanelChange1">
</a-date-picker>
JS:
JavaScript
handlePanelChange1(value, mode) {
this.mode1 = mode
console.log(value);
console.log(mode);
this.state.time = value
this.state.isopen = false
},
changeopen() {
this.state.isopen = true;
}
效果:
主要通过 focus 实现该日期框的打开和关闭, 使用panelChange 获取当前选择的年份。