用format设置日期格式
用change实现时间发生变化的时回调
<template>
<a-range-picker
show-time
format="YYYY-MM-DD HH:mm:ss"
@change="onChangeRangeDate"
/>
</template>
<script lang="ts" setup>
import { reactive } from "vue";
const collectionSearchValue = reactive({
startTime: "",
endTime: "",
});
// 获取选择的时间
const onChangeRangeDate = (dates: [moment.Moment, moment.Moment]) => {
if (dates) {
collectionSearchValue.startTime = dates[0].format("YYYY-MM-DD HH:mm:ss");
collectionSearchValue.endTime = dates[1].format("YYYY-MM-DD HH:mm:ss");
}
};
</script>