import moment from 'moment';
state = {
dataopen: false, // 默认是否打开弹框
year: moment(),
}
// 点击选择框事件 弹出日期组件选择年
openChangeYear = (status) => {
if (status) {
this.setState({ dataopen: true });
} else {
this.setState({ dataopen: false });
}
}
// 选择年之后 关闭弹框
panelChangeYear = (value) => {
let years = value.format('yyyy');
this.setState({ dataopen: false, years: years }, () => {
console.log('years', years)
});
}
handleYearChange = (value) => {
let years = value.format('yyyy');
console.log('years', years)
};
<DatePicker
style={{ width: '140px', marginTop: '-3px' }}
onChange={this.handleYearChange}
placeholder="请选择年"
mode="year"
v-model="queryParam.years"
open={this.state.dataopen}
format="YYYY"
allowClear="false"
onOpenChange={this.openChangeYear}
onPanelChange={this.panelChangeYear}
/>
|