需要引入 moment
format="YYYY" 只显示年
<a-date-picker format="YYYY"
mode="year"
:open="endOpen"
@openChange="endOpen = true"
@panelChange="yearChange"
v-model="year">
</a-date-picker>
data:{
endOpen: false,
year: moment(),
}
method:{
yearChange(val) {
this.year = moment(val, 'YYYY');
this.endOpen = false;
this.timeConfig = {
type: "year",
value: val,
tags: this.timeConfig.tags,
};
},
}