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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM