废话不多说,直接上代码:
<template>
<div class="page-main">
<a-range-picker
value-format="YYYY-MM"
format="YYYY-MM"
v-model="billMonth"
:open="monthPickShow"
@panelChange="handlePanelChange"
@openChange="handleOpenChange"
:mode="['month', 'month']"
id="timePicker"
/>
</div>
</template>
<script>
import moment from 'moment'
export default {
name: 'monthPiker',
data() {
return {
monthPickShow: false,
billMonth: [],
}
},
methods: {
handlePanelChange(value, mode) {
// mode 的值为 'date' 时,即是选择了时间
this.monthPickShow = mode[1] === 'date' ? false : true
this.billMonth = [moment(value[0]).format('YYYY-MM'), moment(value[1]).format('YYYY-MM')]
},
handleOpenChange(status) {
this.monthPickShow = status ? true : false
},
</script>
旨在分享~~~~~~~~~~~~~~~