JS部分:
data()?{
????return?{
??????pickerOptions:?{
????????disabledDate(time)?{
??????????/**
??????????*?大于當(dāng)前月分的日期不可選
??????????*/
??????????//獲取時間惠勒,當(dāng)前的月份
??????????const?date?=?new?Date()
??????????const?year?=?date.getFullYear()
??????????let?month:?any?=?date.getMonth()?+?1
??????????if?(month?>=?1?&&?month?<=?9)?{
????????????month?=?'0'?+?month
??????????}
??????????const?currentdate?=?year.toString()?+?month.toString()
??????????//?獲取時間選擇器上選擇的月份????
??????????const?timeyear?=?time.getFullYear()
??????????let?timemonth:any?=?time.getMonth()?+?1
??????????if?(timemonth?>=?1?&&?timemonth?<=?9)?{
????????????timemonth?=?'0'?+?timemonth
??????????}
??????????const?timedate?=?timeyear.toString()?+?timemonth.toString()
??????????return?time.getTime()?<?new?Date(new?Date().getFullYear().toString()).getTime()?||?currentdate?<=?timedate
????????},
??????},
??????value1:?'',
????}
??}
HTML部分:
?<el-date-picker
??????????v-model="time"
??????????type="month"
??????????size="mini"
??????????popper-class="yy-time"
??????????value-format="yyyyMM"
??????????placeholder="選擇年月"
??????????@change="fetchData"
??????????:style="{?width:?getSwitchWIdth(120)?+?'px'?}"
??????????:clearable="false"
??????????:picker-options="pickerOptions"
????????></el-date-picker>