<u-datetime-picker
:show="dateShow"
v-model="dateValue"
mode="date"
:formatter="formatter"
:maxDate="maxDate"
:minDate="todayData"
@confirm="dateConfirm"
@cancel="dateCancel"
></u-datetime-picker>
data() {
return {
dateShow: false,
dateValue: Number(new Date()),
}
}
onLoad() {
this.todayData = Date.now();
this.maxDate = Number(new Date("9023-01-01"));
},
methods: {
dateConfirm(value) {
console.log(value, '日期选择-确定')
},
dateCancel() {
this.dateShow = false;
},
formatter(type, value) {
if (type === "year") {
return `${value}年`;
}
if (type === "month") {
return `${value}月`;
}
if (type === "day") {
return `${value}日`;
}
return value;
},
}