a-month-picker 禁止当前完后月份,禁止当前往前推2月份
作者:互联网
<template> <div> <a-month-picker v-model="monthPicker" :disabled-date="disabledDate" placeholder="选择月份" @change="onChange" /> </div> </template> <script> import moment from 'moment' export default { name: 'Fullcalendar', data () { let that = this return { monthPicker: '', dateFormat: 'YYYY-MMD' } }, mounted () {
this.rangeFC() }, methods: { moment, rangeFC () { this.monthPicker = '' this.monthPicker = moment(this.getCurrentData(), this.dateFormat) this.$parent.onMonthPick(this.monthPicker) }, getCurrentData () { let time = new Date().toLocaleDateString() return time }, onChange (val) { let A = moment(val).format('YYYY-MM') if (A === 'Invalid date') { this.rangeFC() } else { this.monthPicker = moment(val).format('YYYY-MM') } }, disabledDate (current) { const date = new Date() let month = date.getMonth() + 1 // 禁止当前月往前推2月且后面月份不可选 return current.month() < month - 3 || current > moment().endOf('day') }, beforeDestroy () {} } } </script> <style> </style>
标签:picker,禁止,val,完后,rangeFC,month,moment,let,monthPicker 来源: https://www.cnblogs.com/huoshengmiao/p/15562077.html