antd日期选择框只能选择年份
vue页面代码:
<h4 class="mt10">年度</h4> <a-date-picker mode="year" v-model="year" format="YYYY" :open='yearShowOne' @openChange="openChangeOne" @panelChange="onYearChange" style="display: block; width: 100%"/>
导入moment :
import moment from 'moment'
data数据:
data(){
return {
year:null,
yearShowOne:false
},
}
},
methods方法:
// 弹出日历和关闭日历的回调
openChangeOne(status){
//status是打开或关闭的状态
if(status){
this.yearShowOne = true
}
},
// 得到年份选择器的值
onYearChange(value){
this.year = moment(value).format('YYYY');
this.yearShowOne = false
},

浙公网安备 33010602011771号