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
},
